Telegram inline keyboard does not send callback for acknowledging alert

Doesn’t each telegram callback have to…er…call back into your HA instance? Does this not necessitate it being accessible from outside anyway?

I meant there is no accesible HA URL from outside. VPN is necessary. HA can access the internet.

Yeah, but a telegram callback requires a way to get back to your HA system somehow. Maybe I don’t understand your use case.

There is definetly no need to expose HA for telegram callback. It works without.

https://www.home-assistant.io/integrations/telegram_polling/

Right…I was using the webhook method…I completely forgot that it could work with polling as well!

Hey Axel - I have been playing around and think I have worked out the inline_keyboard problem. I found another post saying that inline keyboard responses need to be treated as callback queries not commands, where all other inputs are direct commands.

Anyway I then used this event node - Which when I dragged it on the sheet was a Callback query
image


I then paired this to a switch node that was listening for the /command (/disarm in my case) which then went to a home assistant call service node to turn off the alarm.
Works perfectly (except the button doesnt show on the lock screen until I have unlocked the phone). Hope that helps?

1 Like

Hi Neil, works like a charm. Thank you very much! :partying_face: :pray:

1 Like

hey @brix29

whats your modified code after implementing the changes from @neilma ?

Gah! I cracked this issue. I am not sure why it stopped working, but here’s what got it working for me:

I’m using commands and callbacks with the same data/command to reduce the number of automations.
The documentation on HomeAssistant use to say use

target: '{{ trigger.event.data.user_id }}'

but switching it to this after looking at logs did the trick (cause looking for a common ‘target’ to send the message to that’s present in both callback and command json).

target: '{{ trigger.event.data.chat_id }}'

Sooo I guess someone changed something in one of the releases and we missed it on breaking changes? I certainly did.

Here’s an example of how I’ve written one of many of my automations for my telegram bot:

  - alias: Telegram bot light menu command
    id: telegram-light-menu-cmd
    trigger:
    - event_type: telegram_callback
      platform: event
      event_data:
        data: /lights
    - event_type: telegram_command
      platform: event
      event_data:
        command: /lights
    action:
    - service: telegram_bot.send_message
      data_template:
        target: '{{ trigger.event.data.chat_id }}'
        callback_query_id: '{{ trigger.event.data.id }}'
        message: AZIZ! Your lighting options
        disable_notification: true
        inline_keyboard:
        - 🛋️ Lounge lamp:/lamplounge, 🪔 Entrance hall lamp:/lamphall
        - 🔪 Kitchen main light:/lightkitchenmain, 🗄️ Kitchen counter light:/lightkitchencounter
        - 🚪 Front door light:/lightfrontdoor, 🏡 Garden light:/lightgarden
        - 📶 Loft stairs:/lightstairs, 🌈 Landing LED:/lightled
        - 🔙 Back to options:/options
2 Likes

Fantastic! Thanks! Answers this

yer-welcome! :wink: