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?
Server location is really important if you want a really fast bot! The distance between your server and Telegram servers adds a delay in your responce time. The closer your server is to Telegram ones the ligher the lighter the delay becomes!
Security researchers have previously found Telegram bots that command and control malicious Android apps, and even exfiltrate data from Telegram chats through the Telegram bot API used by developers.
The main advantage of webhooks over long polling is that they are cheaper. You save a ton of superfluous requests. You don't need to keep a network connection open at all times. You can use services that automatically scale your infrastructure down to zero when no requests are coming.
Oracle Cloud It is more than capable of hosting a Telegram bot using its functions service in the PaaS branch.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With