Discord alerts for new theses
Post a Discord message whenever a thesis lands on your token.
Post a message to a Discord channel whenever someone publishes a thesis on your token. A long-running bot uses a stream; a serverless function uses a webhook. Both take a few minutes.
Create a Discord webhook
In Discord, open Channel settings → Integrations → Webhooks, create one and copy its URL into DISCORD_WEBHOOK_URL. Treat it like a secret.
Subscribe and forward
The SDK keeps the stream connected, sends heartbeats and resumes from the last cursor after a disconnect, so the bot never misses a thesis while it's restarting.
import { FomoData } from "@fomodata/sdk";
const fomo = new FomoData({ apiKey: process.env.FOMODATA_API_KEY });
fomo.streams.subscribe({
event: "thesis.created",
token: "$RUN",
async onEvent(event) {
const { profile, token, text } = event.data;
const label = event.livemode ? "" : "[sandbox] ";
await fetch(process.env.DISCORD_WEBHOOK_URL!, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
content: `${label}**${profile.handle}** posted a thesis on **${token.symbol}**\n> ${text.slice(0, 300)}`,
allowed_mentions: { parse: [] } // never ping @everyone from user text
})
});
}
});Label sandbox data
With a test key you'll receive sandbox events. The bot prefixes them with [sandbox] so nobody mistakes a fixture for real Fomo activity.
Or: serverless with webhooks
No always-on process? Create a webhook for thesis.created filtered to your token and forward from the handler. Reply 2xx quickly; Discord calls can happen after.
// app/api/fomodata/route.ts (or any Fetch-API runtime)
const fomo = new FomoData({ webhookSecret: process.env.FOMODATA_WEBHOOK_SECRET });
fomo.webhooks.on("thesis.created", async (event) => {
await postToDiscord(event); // same fetch() call as above
});
export const POST = (request: Request) => fomo.webhooks.handle(request);Good citizenship
- Discord rate-limits webhooks. For busy tokens, batch alerts (for example, one message per minute listing new theses).
- Keep attribution: link to the author's public Fomo profile (
profile_urlfrom profiles) when you have it. - Use
token.thesis_velocityfor "this token is heating up" alerts instead of one message per thesis.