skip to Main Content

Curious, if there is way to avoid skipping messages sent from Telegram Bot while web-server that accepts Webhooks is down (because of redeploy, failure or maintenance).

When you use polling – Telegram API sends messages starting from last retrieved and no message are skipped.

But how to be with Webhooks? Use polling or there are some special mechanism for that?

2

Answers


  1. I had the same problem recently but I just resolved it by when the server starts save the started time to a variable and then use Telegrambot.Message.date and compare the time if it was sent before the server start time or not.

    Login or Signup to reply.
  2. Telegram keeps the incoming message for 24hrs, if you are Webhook is down (ie redeploying) then the message will be delivered once it is again online.

    It works on Heroku for example where your Dyno is down: as soon as it starts the Chatbot will register again with Telegram and will receive the messages still available in the queue.

    There are two mutually exclusive ways of receiving updates for your bot — the getUpdates method on one hand and Webhooks on the other. Incoming updates are stored on the server until the bot receives them either way, but they will not be kept longer than 24 hours.

    See Telegram documentation for more details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search