Is it possible to get multiple telegram bots?

I participate in several Telegram groups, and I want each group to have its own bot.

Yes, I can have a single bot talking to different channels/groups, that’s what I do now, but I still think having separate bots is more elegant and better maintainable.

1 Like

Indeed. And as @lugia already mentioned in the feature request, it’s just better readable and maintainable if you have the possibility to work with multiple Telegram bots as you can give them different names.

I just use different chat groups. The one home assistant bot can notify my General alert group that everyone has access to, or the System group that only I have access to.

I have a telegram group for all our family members. In this group go automated announcements (washing machine needs emptying, bins need taking out, etc.)

Variety is the spice of life so I use different telegram bots for different areas; health (“don’t forget to take your tablets”, “well done you’ve run 200km this month!”), household (“you’ve left home but the lights are still on”), gaming (“two of your steam friends are playing terraria, do you want to go join them?”).

I do this by using node-red. Node-red has a little hurdle to get to figure it out but once you do it’s brilliant. It has some great telegram nodes that you can use to interact with your bots and process information, requests, etc.

This is the best way I have found for having multiple telegram bots in Home Assistant

im afraid this method does not work in 2022.09. basically, i want to send alerts to other people’s Telegram account. has anyone figured out a way?

I’m waiting for a solution for multiple bots too. In domoticz I could use multiple bots and send message to my girlfriends phone through her bot and to my phone to my bot. I know I can use a group account but I dont want that. Hopefully someone figures it out.

This is my notifiers.yaml:

  - name: tg_house_group
    platform: telegram
    chat_id: -123456789
  - name: tg_house_andy
    platform: telegram
    chat_id: 987654321
  - name: tg_house_larry
    platform: telegram
    chat_id: 567894321

configuration.yaml:

telegram_bot:
  - platform: broadcast
    api_key: !secret telegram_bot_api
    allowed_chat_ids:
      - -123456789
      - 987654321
      - 567894321

Because it’s using the broadcast platform, it cannot receive messages back from telegram.

I have now set it up to use groups, in the end better I have now a group called Home Assistant alerts with the logo so that is cool. So I created a group for me with my bot and one for my girlfriend with my bot. That worked so far. However when I use the notify.telegram_jd it is sending messages to both groups instead of only my group. I want notify.telegram_jd to sent to my group and notify.telegram_ca to my girlfriends group only.

This is how my config looks like

@JDv1 - have u managed to fix it?
The things which little conusing me is that user_id ,
user_id is uniq (single one ) for each telegram account ,
where the chat_id is created for each group.
so i did the following
1.create Bot_X → added to new group_A → chat_id -8XXXXXXXX
1.create Bot_Y → added to new group_B → chat_id -8XXXXXXXX

telegram_bot:
  - platform: polling
    api_key: !secret api_telegram_token
    allowed_chat_ids:
      - !secret userid_telegram    
      
telegram_bot:
  - platform: polling
    api_key: !secret security_telegram_token
    allowed_chat_ids:
      - !secret security_userid_telegram  

notify.yaml:

  - name: my-ha
    platform: telegram
    chat_id: !secret userid_telegram
  - name: my-security
    platform: telegram
    chat_id: !secret security_userid_telegram

When i send notification for either notify.my_sequrity or notify_my_ha
it actually send both to group_a chat .

I started a new configuration changed nothing and all of a sudden it works.

@JDv1 - can u please share to config?
did u create 2 bots on same account?
how did u get the chat_id from the bot did u create a group first?

The yaml is still the same as in the picture above. I have one bot and sen to two group ids. One group with bot for me and a group with bot for my girlfriend. One you created the groups add @IDbot to the group and it will give you the id. For me I gave me a number with a minus sign in front of it you have to include this in home assistant so -12345678

Thanks @JDv1 for the explanation - will try and update

Telegram Account
Account -1 is on xxxxx mobile number (My 1st telegram account)
Account -2 is on yyyyy mobile number (my 2nd telegram account)

I want to configure telegram notification on xxxxx mobile number (chat id-111111) & able to push notifications to 1st telegram account on my mobile

I called to service name as abc in home assistant

my second number telegram account with the number yyyyy number and my chat id is 222222
I called to service name as xyz in home assistant

this chat id I added this a Yamal configuration. no configuration error in the home assistant when i check.

when I call service abc it’s not pushing the message to the telegram account with mobile number xxxx. when I call the service xyz for my second telegram account no mobile no yyyy it’s not pushing the message to my snd telegram account
please let me know how can add an additional account

Regards
Sreekant K

I know this is an old thread, but I spent way too much time last night trying to figure this out. This configuration works perfectly for me, thanks for sharing it. :slight_smile:

Thanks for this @PuckStar (post 13 in this thread). One Bot posting to two (or more) chats is good enough for me. Good to know Node-Red can do something if I want to use multiple Bots one day.

Maybe worth mentioning that adding “GetIDs Bot” as a user to your group (three dots / View Group info / Add Members) returns a message with the chat id.
Without the right chat id you get:
[homeassistant.components.telegram_bot] Error sending message: Chat not found.

https://www.home-assistant.io/integrations/telegram/ refers to the GetIDs Bot on initial set-up. Other bots are available, but I need to get out of this rabbit hole. Last thing, I don’t know if it matters, in notify: that initial set-up page has platform followed by name, whereas this solution has name followed by platform.

1 Like

Hi, the way to create 2 bots doesn’t exist yet right?
I can’t use 2 groups and I want to use 2 bots.
Anyone figure it out?

Do not forget to search for your bot, then press start. Steps 5 and 6 in the Telegram integration instructions

изображение
You need to use “-100” before the Telegram group id. And everything will work out)

Thank you very much!
Was having problems and this solved it.