Telegram inline keyboard does not send callback for acknowledging alert

Hi everyone!
I am in despair trying to make telegram inline keyboard (or simple keyboard with command) work.

I am using alert (for leak sensor) in combination with telegram component and it’s inline_keyboard feature for acknowledging the alert.

here is what I have:

telegram_bot:
- platform: polling
  api_key: !secret telegram_hassio_token
  allowed_chat_ids:
  - !secret telegram_hassio_chatid

notify:
- name: telegram_group
  platform: telegram
  chat_id: !secret telegram_hassio_chatid

alert:
  bathroom_leakage:
    name: '*ALERT:* BATHROOM LEAKAGE DETECTED!'
    done_message: '*DONE:* Bathroom leakage has been eliminated'
    entity_id: binary_sensor.bathroom_leak
    can_acknowledge: true
    repeat: 1
    notifiers:
    - telegram_group
    data:
      inline_keyboard:
      - 'Acknowledge:/bathroom_leak_ack'

automation:
- alias: Acknowledge Telegram Alert
  hide_entity: true
  trigger:
  - platform: event
    event_type: telegram_callback
    event_data:
      command: '/bathroom_leak_ack'
  action:
  - service: alert.turn_off
    entity_id: alert.bathroom_leakage

When alert pops up, I get my notification from the bot in my telegram group which looks like the following (which I guess is right):

27 AM

But when I press the ‘Acknowledge’ button, nothing really happens:

What am I doing wrong? May I miss anything in my telegram configuration? Please let me know if you have any ideas. I will appreciate any help. Thank you.

I found this thread because I’m seeing the same thing. I have found that I can type “/command” and my command is received by HA, but clicking on the buttons of the inline keyboard does nothing.

Unfortunately, I can not even send a /command… I think I miss some part of the setup… @SteveDinn can you explain how did you set up you telegram bot so it can send commands to your hassio instance. Thank you.

I am not sure…The one difference that I can see is that I’m using the webhooks platform instead of polling for the telegram_bot component.

I just followed the examples at the bottom of the Telegram Bot page: https://www.home-assistant.io/integrations/telegram_bot/

Have you tried using the Android or iOS notifications yet? It’s really easy to get actionable notifications working with those.

Hi! Thank you very much for your reply. I have only the android device, but I just wanted to make telegram work… I like it because you can see the whole kinda log of actions in your telegram group… So as I understand, you just set up the telegram_bot with webhooks platform and created the notify with platform: telegram and then just created the automations you want… And when you type commands in telegram like /command@your_bot then your hassio instance receives the command and triggers your automation, right? Or am I missing anything?

Btw, I tried using webhooks instead of polling with the same result (the alarm is being sent to telegram with inline_keyboard without any problem, but when I tap on keyboard button nothing happens, I cannot even catch the telegram_callback event in my hassio instance)…

I only do not understand the following part of hassio telegram webhooks documentation:

Using Telegrams setWebhook method your bot’s webhook URL should be set to https://<public_url>:<port>/api/telegram_webhooks .

Where should I set this?

Try to replace command with data in automation.

event_data:
      data: '/bathroom_leak_ack'

@vladosam thanks. I tried, but unfortunately with the same result (((

I took a second look at this. I wonder if the problem is that the notification is being sent via the alert and notify components. I realized that I don’t actually use the notify component with telegram, I use the telegram_bot.send_message service in a script. You might try that and see if you have any more success.

Did you restart hassio after change?

Yep, I did of course.

Then do what @SteveDinn said. I also use telegram_bot and it works just fine.

@vladosam do you mean to use telegram_bot.send_message instead of notify? But how can I do this with alerting?

I don’t think you can use a non-notify service with alerting, but like I said, I don’t use alerts. Maybe just try to send this style of message through the dev-services tool and see if the button works.

yeah, but it breaks the concept of what I want to achieve… recurring messages in telegram which can be stopped (acknowleged) by pressing the inline keyboard button(((

I get you. But if what you’re trying is just not going to work, then wouldn’t you rather know? :slight_smile:

I know ritght! But It is just hard to accept that something that must work, just doesn’t :sob:

@SteveDinn @vladosam I only do not understand the following part of hassio telegram webhooks documentation:

Using Telegrams setWebhook method your bot’s webhook URL should be set to https://<public_url>:<port>/api/telegram_webhooks .

Do you guys know where to set this up?

Is your HA installation publically accessible on the internet, either by NabuCasa or your local IP or duckdns name?

It’s not using HA cloud… It is just accessible publicly over internet using dynamic dns and let’s encrypt… I mean in which file do I set this?