Cloudflare worker to watch RSS feeds and post updates to Discord webhooks
README.md

bzzrt #

A Cloudflare Worker that polls RSS/Atom feeds, summarizes new entries into a readable daily digest with Workers AI, and posts them to Discord channels via webhooks.

Built for "here's what landed today on repo X" updates. Pointed at a Tangled repo's native commit feed (feed.atom?include=commits), it derives the digest from real git activity — so there's no hand-maintained changelog to forget.

Features #

  • Multi-format feed support — Handles RSS, Atom, RDF, and JSON Feed via feedsmith
  • Multi-feed, multi-channel — Monitor any number of feeds and route each to one or more Discord channels
  • AI daily summary — New commits are summarized into a grouped, plain-language changelog via Workers AI (@cf/meta/llama-3.3-70b-instruct-fp8-fast), instead of dumping a raw list. Falls back to a tidy bullet list if the model is unavailable.
  • Once-per-day cadence — A 23h throttle per channel means one digest a day, even though the cron checks more often
  • Deduplication — Tracks the last-posted entry date per feed+channel in Cloudflare KV to avoid reposting
  • Manual trigger — GET /check to force a check + post on demand (bypasses the throttle)
  • Discord embeds — Posts the summary as a rich embed linking to the repo's commit log

Architecture #

feeds.json          — Feed URL → Discord channel mapping
worker.js           — Main worker: cron handler, fetch handler, feed checking, Discord posting
wrangler.toml       — Cloudflare Worker configuration
.dev.vars           — Local-only secrets (WEBHOOKS)

Flow:

  1. On each cron tick (or on GET /check), the worker iterates over feeds defined in feeds.json
  2. For each feed, it fetches the URL, parses it with parseFeed(), and normalizes entries into a common shape
  3. It compares entry dates against the last-posted timestamp (per feed+channel) in Cloudflare KV and keeps only newer entries
  4. Per channel, unless 23h have elapsed since the last post (or force), it holds — so updates land once a day
  5. New commits are summarized by Workers AI into a grouped changelog, posted as an embed to the channel's webhook(s)
  6. The latest entry date per feed+channel is saved back to KV as the high-water mark

Setup #

Prerequisites #

  • Node.js
  • A Cloudflare account with Workers enabled
  • A Cloudflare KV namespace
  • One or more Discord webhook URLs

Configuration #

feeds.json — Map feed URLs to Discord channel names:

{
  "https://example.com/feed.xml": ["general"],
  "https://example.com/blog/atom.xml": ["blog", "general"]
}

WEBHOOKS secret — A JSON object mapping channel names to Discord webhook URLs. Set it as a Cloudflare secret:

npx wrangler secret put WEBHOOKS
# Paste: {"general":"https://discord.com/api/webhooks/...","blog":"https://discord.com/api/webhooks/..."}

For local development, put the same value in .dev.vars:

WEBHOOKS = {"general":"https://discord.com/api/webhooks/..."}

wrangler.toml — Update the KV namespace ID if creating a new one:

npx wrangler kv namespace create KV
# Update the id in wrangler.toml

Development #

npm install
npx wrangler dev --test-scheduled

The worker runs locally at http://localhost:8787. Visit /check to trigger a feed check, or /__scheduled to simulate a cron trigger.

Deployment #

npx wrangler deploy

Wrangler bundles the worker and deploys it to Cloudflare with the cron triggers active.

Scheduling #

The worker is woken twice a day by cron (0 3 * * * and 0 15 * * *, UTC) but posts at most once a day, because of the 23h throttle per channel (MIN_POST_INTERVAL_MS in worker.js). The second wake-up is redundancy, not extra frequency: if Tangled or Discord is unreachable at 03:00, the 15:00 run still gets the digest out, and vice versa. Whichever run first clears the 23h window posts; the other no-ops.

Because 23h < 24h, the post time drifts slightly earlier over time and tends to pin to whichever cron fires first after the window. To lock posting to a fixed time instead, drop to a single cron in wrangler.toml (e.g. just 0 15 * * *) and keep the throttle as a duplicate guard.