How I Fixed Telegram Bot Polling Errors by Switching to Webhook
Back to Blog
Telegram bot

How I Fixed Telegram Bot Polling Errors by Switching to Webhook

Tom Birdy
September 1, 2025
6 min read

I was building a live chat widget with a well known telegram node package: node-telegram-bot-api. As most of devs I am lazy to read through all the docs, once I find a simple solution - I implement it. And it works well most of the time. UNTIL - it doesn't… 😁

My system houses many chats with live running widgets, listening for messages to be forwarded to the attached Telegram bot 🤖.

So I implemented a bot with a polling solution. There are two main methods for receiving user messages: Polling and Webhook. Polling is a method of fetching updates from the Telegram server by periodically sending requests. And it worked well after the start. Until the error appeared 24 hours later:

Telegram Bot polling error:

RequestError: AggregateError at new RequestError (/home/scripts/node_modules/request-promise-core/lib/errors.js:14:15) at plumbing.callback (/home/scripts/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/home/scripts/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/scripts/node_modules/@cypress/request/request.js:183:22) at Request.emit (node:events:518:28) at Request.onRequestError (/home/scripts/node_modules/@cypress/request/request.js:869:8) at ClientRequest.emit (node:events:518:28) at emitErrorEvent (node:_http_client:103:11) at TLSSocket.socketErrorListener (node:_http_client:506:5) at TLSSocket.emit (node:events:518:28) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:90:21) at runNextTicks (node:internal/process/task_queues:69:3) at listOnTimeout (node:internal/timers:555:9) at process.processTimers (node:internal/timers:529:7) code: 'EFATAL'

I restarted the service, thinking that it might be some kind of system glitch. And it happened again after more than 24 hours. Then I started digging and asked AI:

getting a Telegram polling error: aggregate error

A "polling error: RequestError: AggregateError" typically occurs when a Telegram bot, particularly one using the node-telegram-bot-api library, fails to establish a connection to Telegram's servers during the polling process. This error is often linked to network connectivity issues or problems resolving the Telegram API domain. The solution could be found here: https://github.com/windkh/node-red-contrib-telegrambot/issues/345

I was lazy for this complicated solution. After reading this article: https://hostman.com/tutorials/difference-between-polling-and-webhook-in-telegram-bots I stuck to this comparison table:

Key DifferencesPollingWebhook
Communication PatternActive checking by botPassive receipt of updates
Response TimeDelayed by polling intervalNear-instantaneous
Resource UsageHigher (continuous requests)Lower (only processes actual updates)
Infrastructure NeedsMinimal (no server needed)HTTPS server + SSL certificate
Development ComplexitySimple implementationMore complex setup
ScalabilityLimited by polling frequencyBetter for high traffic

👌 So I decided to go with Webhook method, because Polling is a simple and quick way to develop, at the early stages, while Webhook offers more efficient message processing for production environments. After Webhook implementation no more polling errors appeared ever… 😅😎

Want to try BirdyChat widget for free?

Start chat with your customers via Telegram-powered widget.