7

I've created a telegram bot and set a webhook as described in the docs. For testing purposes I've set it up so once you send the bot a message it replies back with the same message.

Now the issue I am having is that the updates from telegram are coming back really slowly and there are some messages I haven't received yet. Am I missing something or is the webhook method just really slow?

user1686342
  • 1,265
  • 1
  • 18
  • 24

1 Answers1

5

I had the same problem. Turns out I wasn't responding the telegram server after I got the POST request. Due to this, the server wasn't sure if I got the previous updates and was constantly sending my webhook past updates.

I have an express server and I added this bit of line after handling the POST Request.

res.sendStatus(403)

You can also confirm this by going to this url

https://api.telegram.org/<token>/getWebhookInfo

You'll see a property called pending_update_count. It should zero or close to it.

Aditya
  • 677
  • 2
  • 9
  • 15
  • In my case, I returned the response via js Promise - and your answer made me think that perhaps Telegram API doesn't like it all so much, which turned out to be correct.. – Shaya Nov 22 '18 at 00:37
  • 1
    Why not send back status 200 though? – Shaya Nov 22 '18 at 00:42