A Cloudflare Workers + Workflows project that listens for Telegram updates, scrapes any URLs in incoming messages, cleans and extracts the main text, summarizes the content via Google Gemini AI, and replies back to the user with concise summaries.
- Auto-detects URLs in Telegram messages
- Fetches and cleans HTML (removes scripts, ads, nav, etc.)
- Uses Google Gemini API for 3-sentence summaries
- Replies via Telegram Bot API with link previews disabled
- Node.js ≥18
- pnpm (or npm/yarn)
- Cloudflare account with Workers & Wrangler CLI
- Telegram Bot Token (obtainable from @BotFather)
- Google Gemini API Key (Generative Language API) (get one here)
Clone this repo and install:
git clone https://github.com/b0r3k/telegram-link-summarizer-cf.git
cd telegram-link-summarizer-cf
pnpm installLog in to your Cloudflare account if necessary:
npx wrangler loginSince we need a public URL for the Telegram webhook, there is no simple way to test this locally. Instead, we will deploy the Worker and set up the webhook to point to it.
Set the secrets for your deployment:
npx wrangler secret put TELEGRAM_BOT_TOKEN
<input token when prompted>
npx wrangler secret put GEMINI_API_KEY
<input key when prompted>Deploy. If prompted, create your worker subdomain.
npx wrangler deployAfter deployment, set the bot webhook:
curl -F "url=https://telegram-bot-workflow.<YOUR_WORKER_SUBDOMAIN>.workers.dev" \
https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook.
├── .dev.vars # Local env vars (git-ignored)
├── wrangler.jsonc # Wrangler & Workflow config
├── src/
│ ├── main.ts # HTTP entrypoint & Workflow trigger
│ └── workflow.ts # WorkflowEntrypoint implementation
├── tsconfig.json
└── package.json
- Send any message containing one or more URLs to your Telegram bot.
- The Worker enqueues a Workflow that:
- Scrapes each URL in parallel
- Cleans HTML, extracts text
- Calls Google Gemini to summarize
- Sends a single Telegram message with all summaries
To remove the webhook and stop the bot from responding to messages, run:
curl https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook