Long polling is the Telegram Bot API's alternative to a webhook: the bot repeatedly calls the getUpdates method with a timeout, and Telegram holds the connection open until a new update arrives or the timeout expires, then the loop repeats. It requires no public HTTPS endpoint, which makes it the simplest way to receive updates from a script running on a laptop or a private network. Only one delivery mode is active at a time — setting a webhook stops getUpdates from returning anything, and deleting the webhook is required before polling resumes.
Each call to getUpdates returns any updates that arrived since the last acknowledged offset, then blocks for up to the requested timeout waiting for the next one if none are queued. The receiver must persist the highest update_id it has processed and pass offset = update_id + 1 on the next call, or Telegram will redeliver the same updates on every request.
Long polling needs no TLS certificate, no public port, and no firewall rule — a bot on a laptop behind NAT can receive updates the moment it starts the loop. That makes it the default choice for local development and small scripts, at the cost of needing a persistent process: the loop stops receiving the instant the process dies, with no automatic retry from Telegram's side the way a webhook gets one.
Autogram runs as a fleet of stateless Celery workers rather than one long-lived process, so it registers a webhook and lets Telegram push updates to an HTTPS endpoint on arrival. That fits a horizontally-scaled backend better than a loop that has to run somewhere continuously — and it is why the two Bot API delivery modes are mutually exclusive on the same bot token.
Automate your Telegram publishing with AI content, quality scoring, and smart scheduling.