Telegram bot webhook vs polling: which should you use?
A Telegram bot needs a way to receive messages from users. Telegram offers two methods: long polling and webhooks. You use one or the other, not both at the same time.
Long polling
Your bot asks Telegram for new updates again and again using the getUpdates method. It is the default in most libraries, such as python-telegram-bot, aiogram and node-telegram-bot-api.
- Easy to set up, since you only need the token.
- Works from any machine, even your home PC.
- No domain or HTTPS certificate required.
- The bot process must be running all the time.
Webhooks
You tell Telegram a URL, using the setWebhook method, and Telegram sends each update to that URL as it happens.
- Needs a public HTTPS address that Telegram can reach.
- Telegram documents a limited set of supported ports, including 443, 80, 88 and 8443. Check the official Bot API docs for the current list.
- Your bot must run a small web server to accept the requests.
- Can be efficient for busy bots.
Which should you pick?
- Small or hobby bot: use polling. It is simpler and has fewer things to go wrong.
- Bot with a domain, SSL certificate and a web server: a webhook can work well.
- Unsure about port access on your hosting plan: start with polling and ask support before attempting a webhook.
Common mistakes
- Running polling while a webhook is still set. Telegram will refuse to deliver by polling, so remove the webhook first with deleteWebhook.
- Starting two copies of the same bot, which causes conflict errors.
- Using a self-signed certificate without uploading it correctly.
Quick check
Telegram provides getWebhookInfo, which shows whether a webhook is set and the last error it hit. It is the fastest way to debug delivery problems.
If you are not sure which approach fits your plan, ask in our Discord before you build around one.