Status: inferred · Last reviewed: 2026-07-10

Deploy a Telegram Bot for Free

A Telegram bot can run by long polling on a normal server or receive webhooks in a serverless function. For free hosting, webhooks on Cloudflare Workers are usually the cleaner architecture because there is no idle process to keep awake.

ChatGPT Telegram Workers · tbxark/ChatGPT-Telegram-Workers

Use Telegram webhooks with Cloudflare Workers for an event-driven bot without a sleeping server.

Use Render only when the bot library requires long polling or a normal Node/Python process.

Store the bot token as a secret and verify a secret webhook path or header.

Make updates idempotent because Telegram can retry webhook delivery.

Best free hosts

Cloudflare Pages is the primary recommendation for this deployment path.

Deployment path

  1. 1 Create the bot with BotFather and keep the token out of source control.
  2. 2 Implement an HTTPS POST handler that parses Telegram updates and returns quickly.
  3. 3 Store `BOT_TOKEN` and a webhook secret with the platform's secret manager.
  4. 4 Deploy the Worker and register its HTTPS URL with Telegram's `setWebhook` method.
  5. 5 Verify the secret, deduplicate update IDs and move slow external calls behind controlled retries or queues.
  6. 6 Test commands, malformed updates, duplicate delivery and downstream API failure before sharing the bot.

Why webhooks fit free hosting

Telegram sends each update to an HTTPS endpoint, so the platform runs code only when a message arrives. This maps naturally to Workers and avoids artificial keep-alive traffic. Return promptly; if the bot calls a slow AI API, design retries and duplicate protection explicitly.

Security and reliability

Keep the token in encrypted secrets, use Telegram’s webhook secret token or an unguessable path, and never log message content unnecessarily. Track processed update IDs when duplicate side effects would matter. Add rate limits per chat and cap user-controlled prompt size before calling paid external services.

FAQ

Can I host a Telegram bot for free without sleep?

Yes, when the bot uses Telegram webhooks on a request-based platform such as Cloudflare Workers. It does not need a permanently running polling process.

Should a Telegram bot use webhooks or polling?

Webhooks fit serverless free hosting. Polling is easier for some libraries and local development but needs a continuously running process.

Where should bot conversations be stored?

Use durable KV, SQL or an external database. Do not rely on a function's memory or local filesystem between requests.