Telegram Inline Keyboard commands not working on Android

Hi HA community,

I was wondering if somebody uses “Inline Keyboard” with Telegram and Android.

In general, telegram commands are working for me:

service: notify.home_telegram
data:
  title: '*Send a message*'
  message: Alarm
  data:
    keyboard:
      - /alarmoff

Sending a telegram message “/alarmoff” works too. Commands are received by HA.

But “inline keyboard” is not working:

service: notify.home_telegram
data:
  title: '*Send a message*'
  message: Alarm
  data:
     inline_keyboard:
       - Alarm off:/alarmoff

The button on my Android mobile seems to work, but no command is received by HA. The loading wheel on the button is shown for several seconds and disappears again.

Any ideas?

Thank you!

Best,
Axel

Try quoting the keyboard settings:

service: notify.home_telegram
data:
  title: '*Send a message*'
  message: Alarm
  data:
     inline_keyboard:
       - 'Alarm off:/alarmoff'

Colons do funny things in yaml when they are not quoted.

Hi Tom,
thank you for your support. Unfortunalety, colons did not change anything.
Best, Axel

1 Like

Maybe an issue with your phone settings or the Android app?

It’s working on iOS. This works for me:

  action:
  - service: notify.telegram_general
    data:
      title: '⚠️ *House alarm not armed*'
      message: "House alarm is DISARMED and iPhone location is AWAY."
      data:
        inline_keyboard:
        - 'Arm Alarm:/arm'
1 Like

Yes. Seems to be Android related. Using the Web Telegram buttons are not functional, too. Does Web Telegram work for you? (https://web.telegram.org)

Yes, just tested Web Telegram with this,

  action:
  - service: notify.telegram_general
    data:
      title: '📺 *Watch News?*'
      message: "Do you want to watch {{ 'ABC' if trigger.id == 'ABC' else 'SBS' }} news on the lounge TV?"
      data:
        inline_keyboard: "{{'Yes:/abc_news' if trigger.id == 'ABC' else 'Yes:/sbs_news' }}"

It works.

Hmm. That means it’s probably something to do with your telegram integration in Home Assistant.

Any errors in the log?

Have you tried restarting Home Assistant?

1 Like

No errors in my logs.

notify:
  - platform: telegram
    name: Axel Telegram
    chat_id: 150XXXXX
  - platform: telegram
    name: XX Telegram
    chat_id: 169XXXXXXX
  - platform: telegram
    name: Home Telegram
    chat_id: -100XXXXXX

telegram_bot:
  - platform: polling
    parse_mode: html
    api_key: 166XXXX:XXXXXX
    allowed_chat_ids:
      - 150XXXXX
      - -100XXXXX
      - 169XXXXX

Does the config look ok to you?

I just added the parse_mode, because I found some older posts, which recommended using it. No change. :-/

    parse_mode: html

Maybe, it’s the telegram bot settings?

Try adding these trusted networks:

EDIT: No don’t. That is for the webhooks platform only.

telegram_bot:
  - platform: webhooks
    api_key: !secret telegram_api_key
    allowed_chat_ids:
      - !secret telegram_general_chat_group_id
      - !secret telegram_system_chat_group_id
      - !secret telegram_ping_chat_group_id
      - !secret telegram_tom_id
    trusted_networks:
      - 149.154.160.0/20
      - 91.108.4.0/22
      - 127.0.0.1/32

Unless you want to try the webhooks platform.

Note this though:

Hi Tom,

thanks again. Webhooks are not an option for me. I don’t want my HA accessible from outside. That’s why I like the telegram solution.

I will give it a try to setup a new bot. Still not working.

I think I have to stick with the “keyboard” solution.

Cheers, Axel

@neilma solved the problem. Thank you!

Can anyone give me a hint on what the solution would be if not using NodeRed?

Hey @Flop2006, if you are still looking for an answer:

You have to set the event trigger as telegram_callback in your automation for the inline keyboard to work.

2 Likes

Hi @lakhay ! How would it work with url? After following the documentation, I am still not able to get an inline_keyboard to send me to an external url