Send same automated message to two users with Telegram notify

Hello everyone,

I’ve created a bot with Telegram and an automation that sends me a message with some data from my house at an specific time.

For that I have on my config:

telegram_bot:
  - platform: polling
    api_key: !secret telegram_bot_token
    allowed_chat_ids:
      - !secret chat_id1
      - !secret chat_id2

notify:
  - name: Person1
    platform: telegram
    chat_id: !secret chat_id1
  - name: Person2
    platform: telegram
    chat_id: !secret chat_id2

and then I have an automation that has the following action:

  action:
  - data_template:
      message: "Test"
    service: notify.person1

This works fine. However I want to send the same message to both chat ids and I’m not being able to do so without having to add another copy pasted data_template but changing the service to notify.person2 this is super inconvenient since I’m creating a long and customized message.

What is the best way to send the same message to both persons? I’ve played quickly with the notify group config but when I followed some steps then the automation did not work at all.

Any suggestions?

Thanks in advance.

The notify group is what you’re after here.

1 Like

Create a notify group and send it to that.

EDIT: too slow.

1 Like

@Tinkerer @tom_l I’ve tried doing that but failed since I don’t fully understand if that’s gonna fix my issue. The documentation says that I have to include the data for each service I’m calling which does not solve my issue in this case since I want to send the same data_template to both notify services.

Am I missing something? Can you help me with how the configuration for this should look in this specific scenario?

The Notify Group is exactly what you need, but I think you’re misunderstanding the documentation slightly.
As I understand it a Notify Group allows grouping of more than one notification service regardless of platform (e.g. SMS with telegram etc). The documentation part that you’ve mentioned is a requirement that the data items used with a notify group must be supported by all the platforms in the group (e.g. you cannot send a ‘title’ via a group including SMS).
That isn’t relevant in this instance, as you are grouping the same service platform together which is how I do it in my own HA setup.

So your configuration has the group created (in the example I’ve called it ‘all_telegram’):

notify:
  - name: Person1
    platform: telegram
    chat_id: !secret chat_id1
  - name: Person2
    platform: telegram
    chat_id: !secret chat_id2
  - name: all_telegram
    platform: group 
    services:
      - service: Person1
      - service: Person2

And you call:

  action:
  - data_template:
      message: "Test"
    service: notify.all_telegram
3 Likes

Yes, that’s whay I’ve tried the first time with no success.

I just tried it again following your example exactly as it is and the configuration does not error but nothing gets triggered at all once I execute the automation (no message is received on telegram)

EDIT: After FULLY restarting HA the group started working. Partial configuration reload did not work in this case.

I have one of those and it works as expected. I’d check your log file for anything relevant, and run a command line config check to look for any possible errors.

1 Like

That would have been useful to know…

To my knowledge a full restart of HA is always required for changes in configuration.yaml.

Not quite everything, there are quite a few things you can reload. This however isn’t one of them.

1 Like

Thanks for the reminder @Tinkerer - I’m running a fairly static set of devices now so tend to restrict config changes to when I’m updating, and having broken out groups, automations and scripts separately some time ago always forget the re-loadable elements added after I started with HA.