home-assistant.io/source/_components/telegram_bot.markdown
2017-04-12 08:44:39 +02:00

1.7 KiB

layout, title, description, date, sidebar, comments, sharing, footer, logo, ha_release
layout title description date sidebar comments sharing footer logo ha_release
page Telegram chatbot Telegram chatbot support 2017-04-05 18:50 true false true true telegram.png 0.42

Use Telegram on your mobile device to send messages or commands to your Home Assistant.

A command looks like /thecommand

When received by hass it will fire a telegram.command event on the event bus with the following event_data:

command: "/thecommand"
args: "<any other text following the command>"
from_first: "<first name of the sender>"
from_last: "<last name of the sender>"
user_id: "<id of the sender>"

{% linkable_title Configuration samples %}

Simple ping pong example.

alias: 'telegram bot that reply pong to ping'
hide_entity: true
trigger:
  platform: event
  event_type: telegram.command
  event_data:
    command: '/ping'
action:
  - service: notify.notify
    data:
      message: 'pong'

Example that show keyboard interaction with notify.telegram

trigger:
  platform: event
  event_type: telegram.command
  event_data:
    command: '/start'
action:
  - service: notify.telegram
    data:
      message: 'commands'
      data:
        keyboard:
          - '/ping, /alarm'
          - '/siren'

and an automation to trigger a related command "/siren".

trigger:
  platform: event
  event_type: telegram.command
  event_data:
    command: '/siren'
action:
  - service: homeassistant.turn_on
    entity_id: switch.vision_zm1601eu5_battery_operated_siren_switch_9_0
  - delay: 
      seconds: 10
  - service: homeassistant.turn_off
    entity_id: switch.vision_zm1601eu5_battery_operated_siren_switch_9_0