Skip to content

Zero dependencies Telegram bot running on CloudFlare Workers (with durable Workflows) that takes messages, finds links, scrapes content, summarizes using Google AI and sends back.

Notifications You must be signed in to change notification settings

b0r3k/telegram-link-summarizer-cf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Link Summarizer on Cloudflare Workers

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.

Features

  • 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

Prerequisites

Installation

Clone this repo and install:

git clone https://github.com/b0r3k/telegram-link-summarizer-cf.git
cd telegram-link-summarizer-cf
pnpm install

Log in to your Cloudflare account if necessary:

npx wrangler login

Deployment

Since 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 deploy

Telegram Webhook Setup

After 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

Project Structure

.
├── .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

Usage

  1. Send any message containing one or more URLs to your Telegram bot.
  2. 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

Cleanup

To remove the webhook and stop the bot from responding to messages, run:

curl https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook

About

Zero dependencies Telegram bot running on CloudFlare Workers (with durable Workflows) that takes messages, finds links, scrapes content, summarizes using Google AI and sends back.

Resources

Stars

Watchers

Forks