The complete guide to Telegram bot deployment in 2026
Everything you need to deploy a production-ready Telegram bot in 2026 — webhooks vs long-polling, the hosting platforms that actually work, secrets handling, observability, and the gotchas that bite at scale.
I deploy Telegram bots for a living. Here's the playbook, end to end, for a bot that can handle a real user base in 2026.
Architecture in one paragraph
A Telegram bot is an HTTPS endpoint. Telegram sends an update to your endpoint when something happens (new message, button press, payment). Your endpoint processes the update and calls Telegram's API to respond. State lives in your own database. Done.
Webhooks, always
Use setWebhook with your HTTPS URL. Set max_connections to 40-100 depending on traffic. Set secret_token and verify it on every request — without this, anyone can spam your endpoint with fake updates.
```
POST https://api.telegram.org/bot<TOKEN>/setWebhook
{
"url": "https://yourapp.com/api/telegram-webhook",
"secret_token": "<random-32-byte-string>",
"max_connections": 50,
"allowed_updates": ["message", "callback_query"]
}
```
allowed_updates matters — by default Telegram sends every kind of update. Filter to what you actually handle to cut load.
Where to host
Three reasonable choices in 2026:
- Cloudflare Workers: cheapest at scale, zero cold starts, geo-distributed. Best for high-volume bots.
- Fly.io / Railway: easy persistent state, traditional Node.js or Python apps. Best for bots with heavy database work.
- Vercel functions / Netlify functions: easiest DX if your team already uses these. Watch for cold starts on free tiers.
Avoid hosting on a single-region VM unless you're geographically constrained. Telegram's webhook timeout is short; a slow database query plus a 600ms cold start plus 200ms network = failed webhook.
Secrets handling
- Bot token: env var, never in code, rotate on every team change.
- Webhook secret: env var, used to verify the
X-Telegram-Bot-Api-Secret-Tokenheader on every request. - Database creds: managed by your platform's secret store.
If your bot token ever leaks (a commit, a screenshot, a public log), rotate immediately at @BotFather → /revoke. Telegram doesn't notify you about leaks.
State management
Conversation state must live outside the request. Use Postgres or Redis with a key per user (bot:state:<chat_id>). Never use in-process memory — every restart or scale-out drops your users mid-flow.
Observability
What I instrument on every bot:
- Webhook latency (p50, p95, p99)
- Error rate by update type
- Telegram API error rate (especially 429 rate-limits and 403 blocked-by-user)
- Daily active users
- One Sentry alert for any unhandled exception
Telegram's rate limit is 30 messages per second across all users. If you ever broadcast, queue and pace at 25/s with exponential backoff on 429.
The gotchas that bite at scale
- Bot blocked by user returns 403. Mark the user inactive in your DB and stop trying to message them — this saves your global rate budget.
- Long-running handlers. The webhook should respond in under 5 seconds. For anything slow, ACK immediately and process async.
- Multiple instances calling `setWebhook`. Only the most recent one is active. Set the webhook once at deploy time, not on every cold start.
- HTTPS certificate expiry. Telegram silently stops delivering to expired certs. Use a managed cert.
- Updates buffer when your endpoint is down. Telegram retries for ~24 hours. When you come back up, expect a flood — make sure your DB connection pool can handle it.
The deploy checklist
- [ ] Bot token in env, not code
- [ ] Webhook secret verified on every request
- [ ]
allowed_updatesset to what you handle - [ ] State in Postgres/Redis, not memory
- [ ] Webhook latency under 1s p95
- [ ] Sentry or equivalent on unhandled errors
- [ ] Rate-limit handling for 429
- [ ] 403 handling for blocked users
- [ ] Health-check endpoint separate from the webhook
- [ ] Documentation for
/setWebhookrotation
Tick all 10 and your bot will survive its first viral moment. Skip 3 of them and your first 1000-user spike will hurt.
Common questions
- Webhooks or long-polling for production?
- Webhooks. Long-polling is fine for development and tiny bots but it doesn't scale, it's harder to monitor, and it's harder to debug. Production-grade Telegram bots use webhooks behind a stable HTTPS endpoint.
- Can I deploy a Telegram bot on Vercel or Cloudflare Workers?
- Both work. Cloudflare Workers is cheaper at scale and has zero cold starts. Vercel has better DX. For most bots, either is fine — pick the one your stack already uses.
Need this built rather than read about?
I'm a solo developer who scopes, designs, builds and deploys the whole thing. Send a few sentences about your project and you'll get an honest read on scope, timeline and price — usually the same working day.
Oxymore is a one-person studio shipping MVPs, landing pages, React apps and Telegram bots for founders who would rather move than meet.
Last updated