telegram-bot

Webhooks

Introduction#

There are two methods to get messages and informations from your bot:

The /getUpdates function wich is documented pretty straight forward in the spectific section of the documentation

Next: The webhook function which is a bit more complex and often causes issues.

The difference basically is that you use the first alternative to pull changes and react to them and the second one acts more like a push method, by sending a json document.

Setup the webhook

Documented here in the API you see that the syntax of the call is https://api.telegram.org/bot<token>/setwebhook?url=<yoururl>. For the most part this is it. If you need more information, take a look at this guide or look at the requirements (like using HTTPS).

After you set this, you can use the /getwebhookinfo method to get information about your webhook (JSON file). The attributes mentioned in this file are explained in the documentation.

Note that there are several ways to set up your webhook. If you have problems with your webhook always describe how you set up your webhook (with custom certificate/ without …).

Furthermore if you got problems always check if you met the requirements of the webhooks and if your HTTPS certificate is valid.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow