# Telegram bot chat - add a friend

**URL:** <https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146>\
**Category:** General\
**Created:** [7 December 2020 19:46 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146 "2020-12-07T19:46:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [7 December 2020 19:46 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/1 "2020-12-07T19:46:07Z")

</div>

Hi there, I sucessfully used node-red-contrib-telegrambot with a bot created via BotFather, to send and receive messages. So usually I send texts that are interpreted as commands and I generate answers using the initial ChatID.

Now I "just" want to enable a friend that uses Telegram too, to do just the same instead me - so how to get this easiest - is it something I or he need to do in Telegram or in node-red?

So far i have a function to fill the answer like

```auto
var as=global.get('Alarm');
let payload = {
    "chatId":111111111,
    "type":"message",
    "content": "Status "+n+":\n\nAlarm="+as"
};
return {payload};

```

that goes to the telegram sender node..

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 December 2020 20:25 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/2 "2020-12-07T20:25:03Z")

</div>

You may want to create a Telegram group and join to this group your new bot and your friend. As a second step send a message to the group. Now you have to find what is the chatid of the group you just created. You can do that by entering the following URL in your browser:  
[https://api.telegram.org/bot](https://api.telegram.org/bot)(enter here theToken of your bot - without the parenthesis)/getUpdates

You will get in your browser a JSON object that has inside a chatID with a negative sign. A fake example below.

```auto
"chat":{"id":-486232030,"title":"abcdefgroup","type":"group","all_members_are_administrators":true},"date":1606915504,"group_chat_created":true}}]}

```

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [7 December 2020 20:44 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/3 "2020-12-07T20:44:57Z")

</div>

Hmm.. I get

{"ok":true,"result":}

maybe I misunderstood.. ?

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 December 2020 20:47 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/4 "2020-12-07T20:47:45Z")

</div>

This happens when there is no message in the group. Sometimes you have to try twice or three times.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 December 2020 20:51 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/5 "2020-12-07T20:51:24Z")

</div>

Instead of a group, you could also get your friend to add your bot to their account - then they can do the same as you. In Node-RED you would see messages from a different chatid.

But a group works as well, but really that is for if you want both of you to see the inputs and outputs.

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [7 December 2020 21:00 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/6 "2020-12-07T21:00:55Z")

</div>

Hmm.. I did it a lot of times now sending messages .. but no luck. Any other chance to get the group chat ID?

@TotallyInformation: Yes indeed I would like to be able to see all send receive everywhere

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 December 2020 21:08 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/7 "2020-12-07T21:08:09Z")

</div>

> [@loeten](#):
>
> Hmm.. I did it a lot of times now sending messages .. but no luck. Any other chance to get the group chat ID?

I don´t know other alternative to get the chatID. Just to double check. You have sent messages from your Telegram user to the new group, right ?

Edit: a good reference:

> <https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id>

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [7 December 2020 21:39 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/8 "2020-12-07T21:39:04Z")

</div>

> [@Andrei](#):
>
> You have sent messages from your Telegram user to the new group, right ?

yes, also my friend did so and I see his messages in the group, but not with "getUpdates" - maybe my phone eats the update before I can hit F5 in the browser?

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [7 December 2020 21:41 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/9 "2020-12-07T21:41:28Z")

</div>

> [@Andrei](#):
>
> Edit: a good reference:

interesting, there is one comment with the same issue - will test tomorrow to remove and re-insert the bot to the group

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [16 December 2020 09:54 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/10 "2020-12-16T09:54:53Z")

</div>

Just to let you know: removing and re-joining the bot from the chat solved the issue, as well as renaming the group worked for me. All fine now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 February 2021 09:55 UTC](https://discourse.nodered.org/t/telegram-bot-chat-add-a-friend/37146/11 "2021-02-14T09:55:00Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
