Trending Vals

1
stevekrouse avatar
stevekrouse
sqlite
Script
Forked from std/sqlite
9
2
stevekrouse avatar
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
3
stevekrouse avatar
stevekrouse
cerebras_coder
HTTP
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY
43
4
healeycodes avatar
healeycodes
isMyWebsiteDown
Script
Uptime Checker & Status Page Installation Fork this val Edit the list of URLs to what you want to check For the status page, fork this val: @stevekrouse/status
11
5
stevekrouse avatar
stevekrouse
socialDataSearch
Script
Helper function to call SocialData Twitter Search API, via my proxy: @stevekrouse/socialDataProxy
0
6
stevekrouse avatar
stevekrouse
blob_admin
HTTP
Forked from stevekrouse/sqlite_admin
19
7
stevekrouse avatar
stevekrouse
status
HTTP
Uptime Status Page This is the status page for the data generated by this uptime cron: @stevekrouse/uptime
10
8
stevekrouse avatar
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
9
stevekrouse avatar
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
10
nbbaier avatar
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
11
stevekrouse avatar
stevekrouse
getWeather
Script
Forked from sdan/getWeather
4
12
wolf avatar
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
13
valdottown avatar
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
14
stevekrouse avatar
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
15
simplescraper avatar
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
16
pomdtr avatar
pomdtr
extractValInfo
Script
Extract vals infos (author, name, version) from a val url (either from esm.town or val.town ). Example usage: const {author, name} = extractValInfo(import.meta.url) Also returns a unique slug for the val: <author>/<name>
15
17
jonasmerlin avatar
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
18
pomdtr avatar
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
19
stevekrouse avatar
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
20
valdottown avatar
valdottown
templateTwitterAlert
Cron
Twitter/๐• Keyword Alerts [TEMPLATE] Get custom notifications when you, your company, or anything you care about is mentioned on Twitter/X, even if they don't tag you directly. This template will help you: Search for specific mentions on Twitter/X using customizable keywords. Deliver notifications wherever you'd like (email, Discord, Slack, Telegram, etc). Example This val tracks mentions of "Val Town" and related terms, excluding noise like retweets and irrelevant accounts. Notifications are sent to a Discord webhook but can be easily reconfigured for other platforms. To see exactly how we use this template at Val Town: https://www.val.town/v/stevekrouse/twitterAlert Set Up 1. Fork this Val To use this template, fork this val on the top right corner of this 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. Customize Query Define what you want to search for by modifying query : const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity -from:val__run"; Refer to Twitter's search operators to fine-tune your query. 4. Test API call Set isProd = false in the code if you are testing, to ensure there are enough tweets to display. Toggle it back to true when you're ready to run this cron job in production and actuall send notifications. 5. Choose Notification Method This template uses a Discord webhook for notifications, but you can update this to your preferred platform by replacing the discordWebhook call with a call to Slack , @std/email , etc. Create a Discord webhook following this guide . Save your Discord 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, }); ๐ŸŽ‰ Congrats! You now have a val running that ensures you never miss another Twitter/X mention. ๐ŸŽ‰ NOTE: Usage Limits This val uses the SocialData API for Twitter data: Proxies via Val Town's SocialDataProxy : Limited to 10 cents per day for Val Town Pro users . This API is only for Pro users. Need more calls? Sign up for your own SocialData API token and configure the socialDataSearch function.
0
21
stevekrouse avatar
stevekrouse
forwarder
Email
Forked from maas/forwarder
3
22
stevekrouse avatar
stevekrouse
lastlogin_safe
Script
Forked from stevekrouse/lucia_middleware_safe
0
23
stevekrouse avatar
stevekrouse
neatBlackSwift
HTTP
Forked from stevekrouse/cerebras_coder
1
24
mattx avatar
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"]]}
5
25
stevekrouse avatar
stevekrouse
btcPriceAlert
Cron
Forked from panphora/btcPrice
3
26
alexwein avatar
alexwein
fabwbogglelike
HTTP
Forked from fil/earthquakes
0
27
jxnblk avatar
jxnblk
ReactStream
Script
Forked from jxnblk/resrvStreaming
3
28
maxm avatar
maxm
valSession
HTTP
Val Session import { ValSession } from "https://esm.town/v/maxm/valSession"; // Generate a token from your valtown api key. const token = await ValSession.newSession(Deno.env.get("valtown")); // Other services can use it to authenticate const user = await ValSession.validate(token); Fork it, provide your own VT_SESSION_PRIVATE_KEY, and update the hardcoded public key. You can generate your own keys like so: import { crypto } from "https://deno.land/std@0.198.0/crypto/mod.ts"; // Generate a key pair for JWT signing and verification const { privateKey, publicKey } = await crypto.subtle.generateKey( { name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256", }, true, ["sign", "verify"], ); function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string { const lines = b64.match(/.{1,64}/g) || []; return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`; } const privateKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPrivateKey))), "PRIVATE KEY", ); const publicKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPublicKey))), "PUBLIC KEY", ); console.log(privateKeyPem, publicKeyPem);
3
29
stevekrouse avatar
stevekrouse
nominatimSearch
Script
Geocode a free-form description via the Nominatim API The search API allows you to look up a location from a textual description or address. Nominatim supports structured and free-form search queries. Docs: https://nominatim.org/release-docs/latest/api/Search/
0
30
charmaine avatar
charmaine
townieIllustratorPrompt
Script
Add this to Townie's System prompt by going into Townie's Settings โ€” First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface. Core Functionality - Accept an app name as input (e.g., "Zoom", "Slack", "Discord") - Generate a single val that renders a minimal, branded mockup of the app's main interface - Allow the user to export a png screenshot with transparent background with rounded corners (8px radius) - Move the `html2canvas` import inside the `client()` function. - Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side. - Use dynamic import for `html2canvas` inside the `exportAsPNG` function. - Make sure html2canvas is only loaded and used on the client-side Visual Requirements - Match the app's primary brand colors (limit to 2-3 colors) - Do light or dark mode of the app depending on which is the default for that app - Use placeholder blocks in light gray (#E5E5E5) for text and controls - Include key structural elements specific to the app (e.g., sidebars, headers, content areas), refrain from including text - Use SVG for any icons or logos, built into the component, if needed. - Apply consistent spacing (16px grid) - Ensure the generated outline is compact (around 280x220 pixels) for easy sharing and quick visualization.
1