Template

Telegram webhook bot on Cloudflare Workers

Serverless webhook with constant-time secret-token check, replies in the webhook response and a protected /setup route.

Download ZIP (5.6 KB)

SHA-256: 458f6d697c506422a29f82206b4915c00c50839e433d84e32b8c035060fcca60 (checksum file)

Stack: Cloudflare Workers, no runtime dependencies · License: MIT · Files: 11

What it includes

Serverless webhook with constant-time secret-token check, replies in the webhook response and a protected /setup route.

File tree

cloudflare-telegram/
├── src/
│   ├── index.js
│   └── logic.js
├── tests/
│   └── logic.test.js
├── .dockerignore
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── package.json
├── README.md
└── wrangler.toml

Setup

unzip cloudflare-telegram.zip && cd cloudflare-telegram
npm install
cp .env.example .dev.vars
npm test
npx wrangler secret put BOT_TOKEN
npx wrangler secret put WEBHOOK_SECRET
npx wrangler deploy

Fill in .env with credentials from the platform's official developer console. Never commit it: the included .gitignore excludes it.

Run with Docker

docker build -t cloudflare-telegram .
docker run --rm --env-file .env cloudflare-telegram

Official documentation

https://core.telegram.org/bots/api#setwebhook

All templates