brix29
(Axel)
January 31, 2022, 10:44am
1
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
tom_l
January 31, 2022, 10:55am
2
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.
brix29
(Axel)
January 31, 2022, 11:14am
3
Hi Tom,
thank you for your support. Unfortunalety, colons did not change anything.
Best, Axel
1 Like
tom_l
January 31, 2022, 11:53am
4
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
brix29
(Axel)
January 31, 2022, 12:18pm
5
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 )
tom_l
January 31, 2022, 12:27pm
6
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
brix29
(Axel)
January 31, 2022, 12:37pm
7
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?
tom_l
January 31, 2022, 12:41pm
8
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:
brix29
(Axel)
January 31, 2022, 12:57pm
9
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
brix29
(Axel)
February 18, 2022, 9:36pm
10
@neilma solved the problem. Thank you!
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]
[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…
Flop2006
(Flop2006)
July 28, 2022, 8:45am
11
Can anyone give me a hint on what the solution would be if not using NodeRed?
lakhay
(Lakhay)
January 10, 2023, 8:15pm
12
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
mgim
May 18, 2023, 7:07am
13
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