Got problems with webhook to Telegram Bot API

Just another one moment, why your webhooks not work.

In my case the reason was in allowed_updates webhook parameter.

By calling :

https://api.telegram.org/bot<your_bot_token>/getWebhookInfo

You can see

{
  "ok": true,
  "result": {
    "url": "<your webhook url should be here>",
    "has_custom_certificate": false,
    "pending_update_count": 0,
    "max_connections": 40,
    "allowed_updates": [          
      "callback_query"
    ]
  }
}

It means, that your bot can’t react to your text messages, and you will not receive any webhooks!

You can note, that “allowed_updates” contains array. So, currently it will react only to inline button events (passed as keyboard layout!). According to the setWebhook documentation, allowed_updates is an “optional” parameter.

To start receieve text messages, you need to add “message” to your “allowed_updates” prop. To do it, just again set your webhooks and add it to query. Like here :

https://api.telegram.org/bot<your_token>/setWebHook?url=<your_url>&allowed_updates=["callback_query","message"]

You will receive something like “url already added”, but don’t worry, allowed_updates will be updated even in this case. Just try type your message to bot and test your webhooks.

That’s all, now, telegram will send webhooks to each direct message from you to your bot. Hope, it helps someone.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)