SHA-256: 00492049aed9526b45cb79475e64b6c5ff0c07a25fd2da39860e1105bfb45066 (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.
Step-by-step guide
- Download the ZIP above, check its SHA-256 and unzip it.
- Open @BotFather in Telegram, send /newbot and keep the token for wrangler secret put BOT_TOKEN.
- Copy
.env.exampleto.env(or.dev.varsfor Workers) and paste the values. Never commit it. - Install dependencies and run the tests: they pass without network access.
- Run it locally with the commands in the Setup section and send your bot a message.
- Push the folder to a private GitHub repository so a host can build it.
Where to deploy
This template runs on Cloudflare Workers, not on Railway: deploy it with npx wrangler deploy and then call the protected /setup route to register the webhook.
Next steps
Run with Docker
docker build -t cloudflare-telegram .
docker run --rm --env-file .env cloudflare-telegram