Skip to main content

Telegram integration

Documentation:
home-assistant.io/integrations/telegram/
home-assistant.io/integrations/telegram_bot/

 

With the Telegram integration Home Assistant can stablish a bidirectional communication channel with one or more chats, those chats can be people, groups or bots.

To get this working this is a quick summary of the steps:

  • Install Telegram in your computer or phone, create a new bot and gather the information of that bot.
  • Add some lines in the configuration.yaml of your Home Assistant server
  • Usea automations that get triggered when receiving commands sent from Telegram (written in the chat bot) or use automations to send messages (notifications) to Telegram destinations when anything happens in your phone.

Setup

  1. Install Telegram either in your phone or computer. If you don't have an account, create one.
  2. Search for "BotFather" and start a chat with it. Create a new bot using "/newbot". After asking you for a name and username for the bot, it will give you a link to start a new chat with your new bot and an HTTP API token (copy it and save it).
  3. You need to know find the chat id of those chats to which you want to send notifications. You should also find the chat ID of the chat you opened with your bot, since that's the one you should use to send commands from Telegram to your HomeAssistant entity.
  4. Now go to your Home Assistant server, and to the configuration.yaml file, and copy this template:
    # Example configuration.yaml entry for the Telegram Bot
    telegram_bot:
      - platform: polling
        api_key: YOUR_API_KEY
        allowed_chat_ids:
          - CHAT_ID_1 # example: 123456789 for the chat_id of a user
          - CHAT_ID_2 # example: -987654321 for the chat_id of a group
          - CHAT_ID_3
    
    # Example configuration.yaml entry for the notifier
    notify:
      - platform: telegram
        name: NOTIFIER_NAME
        chat_id: CHAT_ID_1
    
      # It is possible to add multiple notifiers by using another chat_id
      # the example belows shows an additional notifier which sends messages to the bot which is added to a group
      - platform: telegram
        name: NOTIFIER_NAME_OF_GROUP
        chat_id: CHAT_ID_2

    now you have to modify it:
    - Where it says "YOUR_API_KEY" please insert the API token you copied before