Use polling unless you have a reason not to
Use long polling for most Telegram bots. It needs no domain, no open port and no TLS certificate, and it works on a free always-on worker. Use a webhook when the bot already lives inside a web app, when you expect heavy traffic, or when your platform only wakes up for HTTP requests. Telegram delivers to one mode per token. While a webhook is set, getUpdates returns an error.
Polling and webhooks side by side
| Long polling | Webhook | |
|---|---|---|
| How updates arrive | Your bot calls getUpdates and waits | Telegram sends an HTTPS POST to your URL |
| Needs a public URL | No | Yes, HTTPS on port 443, 80, 88 or 8443 |
| Process | Always-on worker | Web server; can sleep between requests |
| Typical libraries | aiogram, python-telegram-bot, grammY, Telegraf | Same libraries in webhook mode, or FastAPI and Express |
| Bothosting profile | Node.js or Python polling bot | Node.js or Python webhook bot |
Telegram documents both methods in the Bot API.
Running each mode on Bothosting
For polling, pick a polling profile, save TELEGRAM_BOT_TOKEN and start. Nothing else is needed. For a webhook, pick a webhook profile. Set TELEGRAM_WEBHOOK_URL to the deployment’s HTTPS address ending in /telegram, and set TELEGRAM_WEBHOOK_SECRET so the bot can reject requests that do not come from Telegram. A free Spark site can use your own domain for the webhook too. See custom webhook domains.
Switching without losing messages
Stop the old deployment first. When moving to polling, call deleteWebhook with drop_pending_updates left false so queued messages still arrive. Then start the poller. The step-by-step version is in switching from webhook to polling. For hosting options, see free Telegram bot hosting compared.