FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
Akash11
Akash11twitterAlert
Remix of valdottown/templateTwitterAlert
Public
Like
1
twitterAlert
Home
Code
2
README.md
C
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
README.md

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:

  1. Search for specific mentions on Twitter/X using customizable keywords.
  2. 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. Screenshot 2025-01-10 at 1.22.10β€―PM.png

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. image.png

3. Customize Query

Define what you want to search for by modifying query:

Create val
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:
Create val
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.
Code
README.md
C
main.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.