Readme

Twitter š¯•¸ keyword Alerts

Custom notifications for when you, your company, or anything you care about is mentioned on Twitter.

1. Authentication

You'll need a Twitter Bearer Token. Follow these instructions to get one.

Unfortunately it costs $100 / month to have a Basic Twitter Developer account. If you subscribe to Val Town Pro, I can let you "borrow" my token. Just comment on this val and I'll hook you up.

2. Query

Change the query variable for what you 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!

3. Notification

Below I'm sending these mentions to a private channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever.

TODO

  • Filter out retweets. We've long wanted to filter these out. Should be a quick fix if anyone wants to send me a PR :) Completed by @sumukh
Runs every 20 min
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
import { twitterSearch } from "https://esm.town/v/stevekrouse/twitterSearch";
const query = "\"val.town\" OR \"val town\" -_ValTown_ -is:retweet";
export async function twitterAlert({ lastRunAt }: Interval) {
const results = await twitterSearch({
query,
start_time: lastRunAt,
bearerToken: Deno.env.get("twitter"),
});
if (!results.length) return;
// format results
let content = results
.map(({ author_name, author_username, text, id }) => `https://fxtwitter.com/${author_username}/status/${id}`)
.join("\n");
// notify
await discordWebhook({
url: Deno.env.get("mentionsDiscord"),
content,
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
v23 was merged from the PR "Filter out retweets" by sumukh
Comments
8
boozedog avatar

Hi! I would like to borrow your token please. I just signed up for Pro.

stevekrouse avatar

Sure thing! Let me make you your own private API!

ryi avatar

Hiya! I'd also like to borrow it please if the offer still stands ^-^

stevekrouse avatar

Great! Will email you :)

substrate avatar

Hi Steve! Would love to borrow your token :)

stevekrouse avatar

Sure thing! Will email you :)

charmaine avatar

Hey! Would love to borrow your token to test this out :)

stevekrouse avatar

Sure thing! Will email you :)

v23
June 11, 2024