When you create a bot to serve your telegram clients you need to add a public url to that bot. Once you registered, when updates are available on our bot, our registered url(WebHook) will be called automatically.

Here I will show you the simplest way of how to set telegram bot webhook.

For this tutorial I am using the REST client postman for that, but you can do that with  Insomnia and CURL as well.

Open postman and make HTTP POST request to https://api.telegram.org/bot{Your_bot_token}/setWebhook

For Instance:
https://api.telegram.org/bot00000000:AAAAADFSFVVVSSSSRRRGGGAAASSS/setWebhook

Then, Provide a form-data URL with your public URL. You need to make sure to use the https one. After you’re all set click enter.

set telegram webhook with postman

You should see response like this:

{
    "ok": true,
    "result": true,
    "description":"Webhook was set"
}

That’s it!

Now if you enter the following URL on postman

https://api.telegram.org/bot{your_bot_token}/getWebhookInfo

In our case

https://api.telegram.org/bot00000000:AAAAADFSFVVVSSSSRRRGGGAAASSS/getWebhookInfo

you should see the following message.

{
    "ok": true,
    "result": {
        "url": "https://fdbb70c515dc.ngrok.io",
        "has_custom_certificate": false,
        "pending_update_count": 0,
        "max_connections": 40
    }
}

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *