Home Assistant and Telegram Bot – Targeting Issues

Hi there,

I managed to make my telegram bot work, but I have a problem with targeting my messages to other users.

I defined telegram_bot service with allowed chat IDs in the configuration.yaml plus two notify services, one for me, one for Jo:

telegram_bot:
  - platform: webhooks
    api_key: !secret api_vomacka
    allowed_chat_ids:
      - !secret telegram_jo
      - !secret telegram_sebastian
notify:
  - platform: telegram
    name: 'sebastian'
    chat_id: !secret telegram_sebastian
  - platform: telegram
    name: 'jo'
    chat_id: !secret telegram_jo

But when I try to target a message or a notification, it always sends it only to me.

Here is an example. This is a callback from keyboard from a previous message:

- alias: 'Telegram Bot Ping'
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      command: "/ping"
  action:
    - service: telegram_bot.send_message
      data_template:
        target: !secret telegram_jo
        message: "HEY!"  
    - service: telegram_bot.send_message
      data_template:
        target: '{{ trigger.event.data.chat_id }}'
        message: "Done!"

Instead of Jo getting the message “HEY!” and me getting the message “Done!”, I get both of them.

When I use an automation in HA and I use the notify.jo service, it also sends it to me, so that’s where the problem probably is. I just don’t know why. I triple checked the secrets for chat IDs and they are each different and correct.

I also tried sending a message to Jo’s telegram via API in the web browser address bar and that worked so the User ID is correct.

Does anyone have any idea what I’m doing wrong here?

I’ve got same issue. Did you find the solution?

I just configured Telegram in my HA and I can’t figure what the “target:” should contain? I need a couple of Telegram users to include in my notification/alert.

Has anyone figured this issue out?

Thanks.

Same question/problem here.

I have not updated this thread since I posted my issue here. I went to the r/homeassistant in Reddit and got answers there!

In my case my telegram_bot platform is broadcast. I did not put my api key in the secret.yaml instead I entered it right there in the configuration.yaml. My first allowed_chat_ids is a group chat id of the two chat ids on the next two lines. These worked for me. I can send notification to the individual chat ids or to the group id.

I found this notification settings to work:

- name: telegram_recepient1
  platform: telegram
  chat_id: !secret telegram_user1
  disable_notification: true

- name: telegram_all
  platform: telegram
  chat_id: -1234567890 #  <=== group chat id
  disable_notification: true

Note: I forgot the purpose of the disable_notification was but all my telegram notifications/alerts in HA works for me.