60 setUserID(id);
61
62 // Load props data from API
63 async function loadProps() {
64 const statePropsData = await fetch("/api/state-props").then(res => res.json());
65 setStateProps(statePropsData);
66 }
72 // Load user choices from server
73 async function loadUserChoices() {
74 const choices = await fetch(`/api/user-choices?id=${userID}`).then(res => res.json());
75 setUserChoices(choices);
76 }
84 // Save user choices to server
85 if (userID) {
86 fetch(`/api/user-choices?id=${userID}`, {
87 method: "POST",
88 headers: {
238 ];
239
240 if (url.pathname === "/api/state-props") {
241 return new Response(JSON.stringify(stateProps), {
242 headers: { "Content-Type": "application/json" },
244 }
245
246 if (url.pathname === "/api/user-choices") {
247 const id = url.searchParams.get("id");
248 if (id) {
283 <script src="https://esm.town/v/std/catch"></script>
284 <style>
285 @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700;900&display=swap');
286 h1,h2,h3 {
287 font-family: 'Montserrat', sans-serif;
4
5For now, requires you to be running a board server. This harness actually acts
6as a proxy to the board server [run API endpoint](https://breadboard-ai.github.io/breadboard/docs/reference/board-run-api-endpoint/),
7and puts a nice (well, somewhat nice) frontend on top of it.
8
11
12The script will look for the `BB_COMMUNITY_KEY` in your Val Town environment, which
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
27 const url = new URL(request.url);
28
29 if (request.method === 'POST' && url.pathname === '/api/subscribe') {
30 const { email } = await request.json();
31 await addEmail(email);
86 <title>HumanSnap - Verified Human Photo-Taking App</title>
87 <style>
88 @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');
89
90 * {
294 const email = document.getElementById('email').value;
295 try {
296 const response = await fetch('/api/subscribe', {
297 method: 'POST',
298 headers: { 'Content-Type': 'application/json' },
139 const saveSequence = async () => {
140 try {
141 const response = await fetch("/api/save-sequence", {
142 method: "POST",
143 headers: {
159 const loadSequence = async () => {
160 try {
161 const response = await fetch("/api/load-sequence");
162 if (response.ok) {
163 const savedSequence = await response.json();
228 const url = new URL(request.url);
229
230 if (url.pathname === '/api/save-sequence' && request.method === 'POST') {
231 const body = await request.json();
232 await sqlite.execute(`
238 }
239
240 if (url.pathname === '/api/load-sequence' && request.method === 'GET') {
241 const result = await sqlite.execute(`
242 SELECT sequence FROM ${KEY}_sequences_${SCHEMA_VERSION}
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
12
13### Browserbase
19### Twitter
20
21We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
22
23Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
24
25---
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
12
13### Browserbase
19### Twitter
20
21We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
22
23Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
24
25---
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
12
13### Browserbase
19### Twitter
20
21We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
22
23Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
24
25---
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102