Built a Cloudflare Worker that saves URLs sent via Telegram to a GitHub repository as bookmarks.
It uses worker_threads which isn’t supported. Switched to cheerio for direct HTML parsing instead.
node_compat is deprecated. Use compatibility_flags = ["nodejs_compat"] in wrangler.toml.
Telegram sends a secret token in the X-Telegram-Bot-Api-Secret-Token header that you set when registering the webhook.
To update a file via GitHub API, you must provide the current SHA. Handle 409 conflicts with retry logic for concurrent writes.
Telegram → POST /webhook → Extract URL → Fetch metadata → Save to GitHub
↓ (on failure)
Queue to KV → Cron retries hourly
# Local dev
npx wrangler dev
# Deploy
npx wrangler deploy
# Set secrets
npx wrangler secret put SECRET_NAME
# Create KV namespace
npx wrangler kv namespace create NAMESPACE_NAME