Both transports deliver identical updates. The decision is operational. Polling runs anywhere — no domain, no certificate, no public address — and loses nothing across a restart, because Telegram holds pending updates for you. Its ceiling is hard: exactly one consumer per token. A webhook scales horizontally and trims latency, and in exchange hands you retries, duplicate deliveries and a deploy window. Start with polling. Move when something concrete forces it.
Every Telegram bot tutorial uses long polling, every production guide says use a webhook, and neither explains the trade well enough for you to know which one your bot wants.
The confusing part is that this is not a performance decision, although it is usually framed as one. It is a decision about what you are willing to operate.
The updates are the same
Telegram offers two ways to receive activity. You can call getUpdates and it returns anything waiting. Or you register an endpoint with setWebhook and Telegram posts to it.
The object you receive is identical in both cases. Nothing about your message handling, your state machine or your business logic depends on which you chose — provided you wrote it that way. Keeping the transport behind one thin adapter costs almost nothing on day one and makes the switch a configuration change later, which is worth doing before you know which one you need.
Worth clearing up the name as well: long polling is not a loop that asks every second. The request stays open and returns the moment an update exists, which is why the latency gap between the two is far smaller than the word suggests.
What polling actually gives you
The reason every tutorial uses it is that it imposes no requirements on where the bot runs. There is no inbound connection, so it works on a laptop, behind NAT, inside a container with no ingress, on a machine with no domain name and no certificate. For development that is the whole argument, and for a great many production bots it remains sufficient.
The property that matters more, and gets mentioned least: a restart costs you nothing. Telegram retains pending updates for a limited window and hands them over on your next call. Deploy in the middle of a conversation and the user sees a pause, not a lost message. You get that for free, with no drain logic, no queue, and no load balancer.
The ceiling is equally clear. Only one consumer may call getUpdates for a token — start a second and you get conflict errors rather than shared load. Polling is single-instance by construction. That caps throughput at one process and means an unattended crash is downtime until something restarts it, which is a supervisor's job rather than an architecture problem, but it is yours to arrange.
What a webhook actually costs
A webhook means Telegram connects to you, which starts with the obvious requirements: a publicly reachable HTTPS endpoint, a valid certificate, and one of a short list of permitted ports. On managed hosting that is routine. Behind a corporate firewall it is a conversation with somebody.
Then three things that are easy to miss until they bite.
You must answer quickly. Telegram posts the update and waits for a response. If your handler does the work — calls an API, writes to a database, generates a reply — before responding, slow requests become timeouts and timeouts become retries. The correct shape is to acknowledge straight away and process on a queue. This is the single most common mistake we see in bots that were moved to a webhook without being redesigned for one.
Delivery is at-least-once. Retries mean the same update can arrive more than once, so a handler that charges a customer or creates a ticket will do it twice. Record the update_id you have processed and skip repeats. It is a few lines and it is not optional.
The URL is a credential. Anyone who learns the endpoint can post forged updates to your bot. Register a secret token with the webhook and reject every request whose header does not match. Keep the URL out of logs, screenshots and the repository, exactly as you would an API key.
And the deploy problem the diagram shows: while your process is down, Telegram is posting into nothing. Retries cover some of it; the rest wants connection draining, or a queue in front that accepts the post regardless of whether the worker is up. Under polling you had none of this to arrange.
So which one
Start with polling. Switch when you have a reason you can name.
The reasons that genuinely force a webhook are narrow. You are deploying somewhere with no long-lived process, which is to say a serverless platform, and nothing can sit there holding a request open. Or you need more than one consumer, because a single process cannot keep up or because an unattended restart is not acceptable. Or you have measured a latency requirement that the small gap actually affects.
Volume alone is a weaker reason than people expect. A single polling consumer handles a great deal before it becomes the constraint, and in most bots the bottleneck is the work the handler does rather than the transport that delivered it. If sending is what hurts, the limit you are hitting is on the Bot API's rate limits, and a webhook does not move those.
If you do go webhook
- Acknowledge and queue. Respond immediately; do the work in a worker.
- Deduplicate on
update_idand treat every handler as replayable. - Set a secret token and reject mismatches; treat the URL as sensitive.
- Drain on deploy, or put something in front that accepts posts while workers restart.
- Keep the polling path working in development, so a local run needs no tunnel.
None of that is difficult. It is simply a list that does not exist at all on the other side of the choice, and it is the honest content of “use a webhook in production” — the same kind of operational weight that shows up whenever you take on running a thing yourself.
Questions we get asked
Is a webhook faster than long polling for a Telegram bot?
Slightly, and usually not by enough to decide anything. Long polling holds a request open and returns the moment an update exists, so it is not the delay people imagine from the word polling. The latency difference is small compared with whatever your handler then does. Choose on operational shape rather than on speed, unless you have measured a problem.
Can we run two instances of a polling bot?
No. Only one consumer may call getUpdates for a given bot token, and a second one causes conflict errors rather than sharing the load. That makes polling single-instance by construction, which is fine for most bots and is the hard ceiling when it is not. Needing more than one consumer is one of the few reasons that genuinely forces a webhook.
What happens to updates while the bot is restarting?
Under polling, nothing is lost. Telegram holds pending updates for a limited window and delivers them on your next call, so a deploy or a crash is invisible to users apart from the delay. Under a webhook, Telegram is posting to an endpoint that may not be listening; it retries, but a restart is now a window you have to manage deliberately rather than one that handles itself.
Why does our webhook receive the same update twice?
Because delivery is at-least-once. If your endpoint responds slowly or fails, Telegram retries, and a handler that was already running produces the action twice. The fix is to acknowledge immediately and do the work on a queue, and to make handlers idempotent by recording the update_id you have already processed. Doing the work inline before responding is the most common cause of duplicates.
Does a webhook endpoint need to be secured?
Yes, and the URL alone is not security. Anyone who learns it can post forged updates to your bot. Set a secret token when registering the webhook and reject any request whose header does not match, and treat the endpoint URL itself as a credential that does not belong in logs, screenshots or a repository.
Which should we start with?
Polling, in almost every case, because it runs on a laptop or in a container with no public address, needs no domain or certificate, and survives restarts without special handling. Move to a webhook when something concrete requires it: a platform with no long-lived process, more than one consumer, or measured latency. Keep the transport behind one small piece of code so switching is a configuration change rather than a rewrite.
If a bot is being moved to a webhook because production guides say so, the question worth asking first is which of the three forcing reasons applies. Usually none of them do yet — and that is a fine answer. It is how we decide it on Telegram bot projects.