Browse documentation

Deploy a Telegram bot with polling or webhooks

Create a Telegram bot, run the Node.js or Python example, and verify a private /start message using your chosen delivery mode.

Choose how updates arrive

Long polling lets your process ask Telegram for messages over an outbound connection. Choose it for a first deployment without an HTTP endpoint. Webhook mode lets Telegram deliver each update to a public HTTPS route on your deployment. Choose it when your bot already has an HTTP handler or you want to integrate it into a web application.

Open Telegram bot hosting and choose the Node.js or Python runtime labelled for your mode. One token has one active delivery configuration. Stop any other polling copy before starting this deployment.

Install the example and save the token

Use /newbot in BotFather to create a bot, choose its username and get its token. In the deployment’s Variables, save that value as TELEGRAM_BOT_TOKEN.

To use the supplied example, choose Start with an example and then Add example files in Overview. For a manual upload, use the Node.js example or Python example in Files. For Node.js set MAIN_FILE to index.mjs. For Python use main.py. Both examples use the language’s standard library and support either delivery mode.

Configure HTTPS for webhook delivery

Polling users can proceed directly to the message test. For webhooks, copy the HTTPS address from Settings and append exactly /telegram. Save that full address in TELEGRAM_WEBHOOK_URL. Set TELEGRAM_WEBHOOK_SECRET to a separate random string of 16–256 letters, digits, underscores or hyphens. Set the same two variables when using the Python example.

The sample binds to the assigned SERVER_PORT, registers the URL with Telegram, and checks the secret header on incoming requests. Use the platform hostname first. When moving to your own hostname, complete domain verification before changing the registered URL.

Verify delivery and keep update history

Start the deployment. Open a private chat with the username you created and send exactly /start. Expect Your bot is running. A request to /healthz on the webhook starter checks its HTTP listener. A real message and reply also exercise provider delivery and the outgoing Bot API call.

Keep the project’s .telegram-state directory across restarts. It contains recent update IDs used to suppress duplicate replies. For a mode change or a retry that produces two replies, follow switching from webhook to polling. For updates from source control, use the separate GitHub push webhook.

Deploy your Telegram framework