Clear "pending_update_count" in Telegram Bot

I think you have two options:

  1. set webhook that do nothing, just say 200 OK to telegram's servers. Telegram wiil send all updates to this url and the queque will be cleared.
  2. disable webhook and after it get updates by using getUpdates method, after it, turn on webhook again

Update:

Problem with webhook on your side. You can try to emulate telegram's POST query on your URL. It can be something like this:

{"message_id":1,"from":{"id":1,"first_name":"FirstName","last_name":"LastName","username":"username"},"chat":{"id":1,"first_name":"FirstName","last_name":"LastName","username":"username","type":"private"},"date":1460957457,"text":"test message"}

You can send this text as a POST query body with PostMan for example, and after it try to debug your backend.


For anyone looking at this in 2020 and beyond, the Telegram API now supports clearing the pending messages via a drop_pending_updates parameter in both setWebhook and deleteWebhook, as per the API documentation.