I have been trying to get the most basic example for a command to work with a Telegram bot, but I cannot for the life of me, figure out what I have wrong. My bot is set up correctly and I can send messages A-ok, but when I add the following lines to my automations.yaml
file, nothing happens:
alias: "Telegram bot that reply pong to ping"
triggers:
- trigger: event
event_type: telegram_command
event_data:
command: "/ping"
actions:
- action: notify.notify
data:
message: "pong"
This snippet of code is directly from this page. I have tried adding my Chat ID at the end in the data
field, but this does not work either. What do I have wrong here?
Assuming you’re set up your notification platform as in the docs, shouldn’t that be
actions:
- action: notify.telegram
data:
message: "pong"
Could be due to your notify platform isn’t setup property.
Try with this action instead:
action: telegram_bot.send_message
data:
message: pong
These are the definitions in configuration.yaml
# Telegram Bot
telegram_bot:
- platform: polling
api_key: "59................_T...............hbtfv4d513P8BA"
allowed_chat_ids:
- 123456789
# Notifier
notify:
- platform: telegram
name: "rosamar"
chat_id: 123456789
This is an automation to send a notification:
alias: Notify of Home Assistant Startup
description: ""
triggers:
- event: start
trigger: homeassistant
conditions: []
actions:
- action: notify.rosamar
metadata: {}
data:
message: was just started
title: Home Assistant
mode: single
Thank you all for taking some time to try to help me figure this out!
Unfortunately, none of those suggestions seem to work. I think the issue may lie within the trigger, as I made a test automation that sends messages just fine (on a time based trigger).
EDIT: I figured it out! I needed to add in quotation marks for the command in the web gui view. After I did that, the bot then recognized ‘/ping’ as a command.