Telegram - Multiple receipients

Hi … I was not able to find the answer in the official docs so I have to ask here …
What do I need to send Telegram messages to mutliple receipients (=telegram groups)? Is that possible at all? Is a Telegram bot needed (most of the docs state that one is needed but I see no technical reason).

Thanks,
Tom

Is the issue about sending messages to multiple groups, or is the issue that you don’t know how to send messages from HA via telegram?

I kow how to send messages, but I have not found a way to send a message either to “group A” or “group B”. (It does not have to be sent to both though)

it’s the same thing with sending messages to individuals. you just need to get the group chat ID the same way you get the individual chat ID. Group chat ID normally starts with negative “-”.

So I would add all group chatids here https://home-assistant.io/components/telegram_bot.broadcast/. But where/how can I make use of them then in an automation?
After re-reading https://home-assistant.io/components/notify.telegram/ it should go here? chat_id (Required): The chat ID of your user.
So it’s not the chat_id of my user but the receipient, right?

Made a little progress …
I forgot to add the allowed IDs of the groups to configuration.yaml. This resulted in the following message in home-assistant.log:

WARNING (Thread-4) [homeassistant.components.telegram_bot] Unallowed targets: [-xxxxxxxxx], using default: -yyyyyyyyy

But it still does not work …
What’s not clear to me: do I really need a bot for that?

How do you send messages from HA without a bit than? Therefore my first post.

Just rebuilt all the telegram stuff from scratch in HA. It’s working now. Guess I just fatfingered something somwhere :wink:

In previous versions I have configured HA to work with two Telegram Bots because you only have to configure two bots with their corresponding api keys, without needing a telegram bot.

Now, I understand that you have to configure a bot of the telegram with a key api and then configure the bot of the telegram without key api in notify …

So now I do not know how to configure HA to be able to send notifications to two different bots.

How do you do to work with two or more telegram groups?

I have this configuration, but it doesn’t works:

telegram_bot:
  - platform: polling
    api_key: 000000000:xxxxxxxxx // Group 1 key
    allowed_chat_ids:
      - 1234567 // This is my user_id
  - platform: polling
    api_key: 000000000:yyyyyyyyy // Group 2 key
    allowed_chat_ids:
      - 1234567 // This is my user_id


notify:
  - name: telegram_notifications
    platform: telegram
    chat_id: 1234567 // This is my user_id
  - name: telegram_alarms
    platform: telegram
    chat_id: 1234567 // This is my user_id

Of course, only works one telegram group… I want two telegram groups…

What about this one?

telegram_bot group1:
  - platform: polling
    api_key: 000000000:xxxxxxxxx // Group 1 key
    allowed_chat_ids:
      - 1234567 // This is my user_id
telegram_bot group2:
  - platform: polling
    api_key: 000000000:yyyyyyyyy // Group 2 key
    allowed_chat_ids:
      - 1234567 // This is my user_id

And how can I call the bots to send messages?

Look at the domain thing if there show up two telegram bots and what their names are, maybe? I really don’t know, I was just thinking along and I hoped my proposal would work :slight_smile:

I just created a single bot and added it to two different groups. The messages are sent to the chat_id (of the groups) then.

The same.
I need to receive different kind of information from two bots. On one of my spot I used home-assistant v0.43.2 and all work perfect.
On my new spot with latest home-assistant I can’t do it anymore!

@tmeringer did you managed to get it work ? Previously I was a user of Pushbullet but couldn’t get to work out for multiple recipients. Recently moved to Telegram primarily because of the restriction in pushbullet’s notification numbers in a month (which seems insufficient at the end of month).
However, Telegram is another beast in the town I must say, though it’s bot concept was somewhat difficult to grasp at first, but it’s amazing considering the possibility it offers.

After several attempts, my initial concerns of multiple recipient issue is resolved with Telegram.

The configuration was something like below:

notify:
  - name: telegram_notifications
    platform: telegram
    chat_id: 1234567
#This is my user_id
  - name: telegram_alarms
    platform: telegram
    chat_id: 4567891
#This is second chatID

telegram_bot:
  - platform: polling
    api_key: 000000000:xxxxxxxxx  #user 1 api (user2 API key could be also used; the source of the notification would be changed then)
    allowed_chat_ids:
      - 1234567  #User1 Chat_ID
      - 4567891  #User2_ChatID

To get the chat ID for both users initially, I had to create 2 bots with each users and then following the instruction (in HASS documentation), I could collect the API key and Chat_ID for both users.

I then modified my automation in a way so that notifications are now directed to specific users based on the condition/information. Now I am looking forward to do more automation with camera and Telegram.

Thanks

I want send notification to 2 device. how can i meke automation.

Here is my automation.yaml

- action:
  - data:
      message: Light is on
  - service: notify.telegram_toor
  - service: notify.telegram_mini
  alias: light is on
  id: '67543567847728'
  trigger:
  - entity_id: light.room_21
    from: 'off'
    platform: state
    to: 'on'

Looks good, assuming your notify is as follow:

notify:
  - name: telegram_toor
    platform: telegram
    chat_id: 1234567

  - name: telegram_mini
    platform: telegram
    chat_id: 4567891

How did you find the chat_id of the groups?

Just use web.telegram.org and select the group. The ID can be found in the URL then (?p=g123456789). Just replace “g” with “-” then. So the group ID would be “-123456789” then.

1 Like