Trending Vals
2
stevekrouse
cerebrasTemplate
HTTP
Cerebras Inference template This val shows you how you can deploy an app using Cerebras Inference on Val Town
in seconds. What is Cerebras? Cerebras is an American chip manufacturer that
produces large wafer chips that deliver mind-blowing LLM inference speeds.
As of this writing on Jan 17, 2025, Cerebras Inference
provides Llama 3.18b, 3.1 70b, and 3.370b at a jaw-dropping 2k tokens per second –
that's 50x faster than what the frontier labs produce. Llama 3.370b at 2k tokens
per second is particularly noteworthy because it is
a GPT-4-class model . This level
of intelligence at that level of speed will unlock whole new classes of applications. Quick start Set up Cerebras Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Once Cerebras is set up in your Val Town account, there are two ways to get started: Fork this app and customize it (or ask Townie AI to customize it) Start a new chat with Townie AI and copy & paste
the following instructions: . Use Cerebras for AI on the backend like so:
const { OpenAI } = await import("https://esm.sh/openai");
const client = new OpenAI({
apiKey: Deno.env.get("CEREBRAS_API_KEY"),
baseURL: "https://api.cerebras.ai/v1"
});
const response = await client.chat.completions.create({
model: "llama-3.3-70b",
messages: [],
});
const generatedText = response.choices[0].message.content; For example, the val in this template was created by asking
Townie AI to "Make a chatgpt clone",
then I hit shift-enter twice, and then pasted in the instructions on
how to use Cerebras from above, then hit enter. Townie built this app on its first try, in about 20 seconds. Sample apps Cerebras Searcher - a Perplexity clone that uses the SerpAPI to do RAG
and summaries with Cerebras ( requires a SerpAPI key ) Cerebras Coder - an app that
generates websites in a second with Cerebras Cerebras Debater - an
app that truly shows Cerebras's speed: it's Cerebras talking to Cerebras in a debate
0
3
4
stevekrouse
discordWebhook
Script
Send a Discord message Send a message to a Discord channel from Val Town. It's useful for notifying your team or community when someone interesting happens, like a user signup, Stripe payment, mention on social media, etc. import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
await discordWebhook({
url: Deno.env.get("engDiscord"),
content: "Hi from val town!",
});
Example val: https://www.val.town/v/stevekrouse.discordWebhookEx Setup 1. Create a Discord Webhook Follow the instructions here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks It really only takes 2 minutes. 2. Copy webhook URL Paste it into your secrets as discordWebhook . 3. Send a message! import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
await discordWebhook({
url: Deno.env.get("engDiscord"),
content: "Hi from val town!",
}); Example val: https://www.val.town/v/stevekrouse.discordWebhookEx
1
5
6
10
11
12
nbbaier
sqliteExplorerApp
HTTP
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
21
13
stevekrouse
newStripeSubscriber
HTTP
New Stripe Subscription Handler This val processes new Stripe subscribers to Val Town Pro. It sends our team
a Discord notifcation and sends a welcome email to the new subscriber. It takes a couple of
steps if you'd like to set up something similar for your own Stripe account. Setup Fork this HTTP val Create a new webhook in Stripe Add your val's HTTP endpoint URL into the Stripe webhook Select customer.subscription.updated as the only event to listen to (more on this below) Add your stripe_sk_customer_readonly to your Val Town Env Variables Add your webhook's signing secret as STRIPE_WEBHOOK_SECRET to you Val Town Env Variables How the code is structured Verifies the signature to make sure it's really from Stripe Filters out only newly created subscriptions Sends off the Discord message & email Which Stripe event type to listen to Stripe sends webhooks for many different kinds of events. Relevant for us here are: customer.subscription.created (what we used to listen for) customer.subscription.updated (what we're currently listening for) The issue with customer.subscription.created is that it triggers too early,
before the user's payment actually goes through. This is a problem
because in early Nov 2024 we started getting credit card fraudsters
testing cards using our service. We started getting lots of notifications
for new subscriptions that never actually became active. Note: if anyone knows good ways to prevent that sort of behavior at
the root, please let me know by commenting on this val! In order to only get notified on a valid subscription, we now subscribe
to customer.subscription.updated . This event happens on any subscription change,
including renewals and cancellations, so now we have to filter those events
to only get new subscriptions, ie where: event.data.previous_attributes.status === 'incomplete' && event.data.object.status === 'active'
2
15
stevekrouse
umbrellaReminder
Cron
☔️ Umbrella reminder if there's rain today Setup Fork this val 👉 https://val.town/v/stevekrouse.umbrellaReminder/fork Customize the location (line 8). You can supply any free-form description of a location. ⚠️ Only works for US-based locations (where weather.gov covers). How it works Geocodes an free-form description of a location to latitude and longitude – @stevekrouse.nominatimSearch Converts a latitude and longitude to weather.gov grid – @stevekrouse.weatherGovGrid Gets the hourly forecast for that grid Filters the forecast for periods that are today and >30% chance of rain If there are any, it formats them appropriately, and sends me an email
9
16
stevekrouse
twitterAlert
Cron
Twitter/𝕏 keyword alerts Custom notifications for when you, your company, or anything you care about is mentioned on Twitter. If you believe in Twitter/𝕏-driven development, you want to get notified
when anyone is talking about your tech, even if they're not tagging you. To get this Twitter Alert bot running for you,
fork this val and modify the query and where the notification gets delivered. 1. Query Change the keywords for what you want to get notified for
and the excludes for what you don't want to get notified for. You can use Twitter's search operators to customize your query, for some collection of keywords, filtering out others, and much more! 2. Notification Below I'm sending these mentions to a public channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever. Twitter Data & Limitations The Twitter API has become unusable. This val gets Twitter data via SocialData ,
an affordable Twitter scraping API. In order to make this val easy for
you to fork & use without signing up for another API, I am proxying
SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy
100 times per day, so be sure not to set this cron to run more than once every 15 min. If you want to run it more, get your own SocialData
API token and pay for it directly.
4
17
stevekrouse
aqi
Cron
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast
AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
6
18
mattx
gsheet_call
Script
gsheet_call Wrapper around Google Sheets API v4. Parameters service_account: JSON string containing Google Service Account key sheet_id: Google Sheet ID method: HTTP method to use action: Full URL with https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/ removed data: HTTP request body Requirements a Google Cloud service account the Google Sheets API v4 enabled in your Google Cloud project the spreadsheet ID (provide it in the sheet_id parameter) Instructions Share the spreadsheet with the service account Make a JSON key for the service account, then set it as a secret. Use the secret for the service_account parameter. Figure out the action you want to perform. You will need to provide everything that comes after {spreadsheetId}/ as the action parameter. For example: values/A1:C1:append?valueInputOption=RAW Figure out the request body. For example: {values: [["foo", "bar", "baz"]]}
6
19
jonasmerlin
bluesky_bot_template
Cron
This is a very simple template for the kind of Bluesky bot I build. It's very much all over the place. e.g. it sets up the "Agent" to post (because that part is documented well), but doesn't use it to search for posts. You can do that if you want (if you do, look here ), but I like to simply rawdogg the API, so that is what I'm doing here.
The custom Post type is incomplete and only contains the stuff I found relevant.
Error handling is payed only lip service to (at best) as well. ...But it works for me! How to use If you want to use this, you will have to set 2 environment variables for your val:
BLUESKY_USERNAME
BLUESKY_PASSWORD
From what I can tell from my testing: BLUESKY_USERNAME can be both the bot account's handle as well as the email you use to log into it with. BLUESKY_PASSWORD can be both the account's main password as well as an app password. The rest is commented in the code. If you have any questions, feel free to message me on Bluesky: Jonas-Merlin Schumacher (@jonasmerlin.bsky.social) — Bluesky
2
20
wolf
genericStripeAction
Script
Stripe Webhook Handler To set up stripe webhook handlers for your own project, Fork this script val and the corresponding HTTP val Create a new webhook in Stripe Add your val's HTTP endpoint URL into the Stripe webhook Add your TEST_STRIPE_SECRET to your Val Town Env Variables Add your webhook's signing secret as STRIPE_WEBHOOK_SECRET to you Val Town Env Variables Then, just fill in the handlers to handle stripe events!
1
21
valdottown
templateRedditAlert
Cron
Reddit Keyword Alerts [TEMPLATE] Get notifications when specific keywords appear in Reddit posts. This template will help you: Search Reddit for specific keywords within a defined time range. Send notifications to your preferred platform (Discord, Slack, email, etc.) Reddit does not have an API that allows users to scrape data, so we are doing this with the Google Search API, Serp . Example This val tracks mentions of "Val Town" and related terms on Reddit, filtering results from the last 7 days and sending alerts to a Discord webhook.
Set Up 1. Fork this Val To start using this template, fork this val by clicking the fork button at the top-right corner of the page.
2. View Source Code The CODE box shows you the the full source code of this val, you may need to scroll down to see it.
3. Get a SerpApi Key This template requires a SerpApi key to search Reddit posts via Google search results. Get a SerpApi key : Sign up at SerpApi to create an account. Generate an API key from your account dashboard. Add the SerpApi key to your environment variables : Go to your Val Town environment variables . Add a new key: Key: SERP_API_KEY Value: Your SERP API key. Without this key, the val will not function correctly. 4. Customize Keyword In the CODE box below, update the terms or phrases you want to track:
const KEYWORDS = "\"node\" OR \"node.js\""; 5. Set Up Your Notification Method This template uses a Discord webhook for notifications. You can update this to your preferred platform: Create a Discord webhook following this guide .
Save your webhook URL in your Val Town environment variables: Key: mentionsDiscord Value: Your Discord webhook URL.
Notifications will be sent using this function: await discordWebhook({
url: Deno.env.get("mentionsDiscord"),
content,
}); To switch to another platform (e.g., Slack, email, or custom webhooks), replace the discordWebhook call with the appropriate integration ((e.g., @std/email , Slack , or anywhere else ) 🎉 Congrats! You now have a val running that ensures you never miss another Reddit mention. 🎉 NOTE: Usage Limits SerpApi: Free SerpApi accounts have monthly call limits.
1
23
24
pomdtr
password_auth
Script
Password Auth Middleware Protect your vals behind a password. Use session cookies to persist authentication. Usage import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=84";
export default passwordAuth(() => {
return new Response("OK");
}, { verifyPassword: (password) => password == Deno.env.get("VAL_PASSWORD") }); If you want to use an api token to authenticate: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=84";
import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
export default passwordAuth(() => {
return new Response("OK");
}, { verifyPassword: verifyToken }); TODO [x] allow to authenticate using a val town token [ ] add a way to send an email to ask a password from the val owner [ ] automatically extend the session [ ] automatically remove expired sessions FAQ How to sign out ? Navigate to <your-site>/signout .
15
26
simplescraper
aiEmailAssistant
Email
Email AI Assistant Chat with your favorite AI via email (with PDF attachment support) What It Does This script allows you to: Send emails to OpenAI. The text will be treated as the prompt Parse PDF attachments and include their contents in the AI's analysis. Get response directly to your inbox. Setup guide Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor) Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/) Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address) Write your email, include any attachments, and send it to the Val email address. The AI will respond after a few seconds.
0
27
28
charmaine
redditKeywordSMS
Cron
Reddit Keyword Alert via SMS This Val monitors Reddit for posts with keywords and sends you SMS notifications. Example:
Prerequisites: Twilio account (for SMS notifications) You can create an account with $15 free credits at https://www.twilio.com/ without putting in your credit card SerpApi key (for searching Reddit) Customize all of these according to your preferences: const apiKey = Deno.env.get("SERP_API_KEY");
const twilioSid = Deno.env.get("TWILIO_ACCOUNT_SID");
const twilioToken = Deno.env.get("TWILIO_AUTH_TOKEN");
const fromNumber = Deno.env.get("TWILIO_PHONE_NUMBER");
const toNumber = Deno.env.get("YOUR_PHONE_NUMBER");
const query = "\"node\" OR \"node.js\"";
1