Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram Bot - how to get a group chat id?

I've been using telegram_bot, and trying to get groupChat id to send notifications to group chat, but don't know which methods I have to use for it.

For getting chat id I use to message.chat.id when the bot participated in the chat but which I have to use for getting group chat id can't find/

like image 482
Roman Podpryatov Avatar asked Sep 06 '15 12:09

Roman Podpryatov


People also ask

How can I get telegram Bot chat ID?

Type “ @RawDataBot ” and select “Telegram Bot Raw” from the drop-down list. Click on the “Start” button in the auto-reply message. The Telegram bot will send a message with your account info. Scroll down and find “Chat.” Your chat ID number is listed below, next to “id.

What is a Telegram chat ID?

Note the number next to "ID." The number next "ID" below "Chat" in Telegram Bot Raw's message is the chat ID for the entire group.

How to add a bot to a telegram group?

In your telegram, create a new chat group and add the bot that you have created into the chat group. 2. To get the chat ID of the group chat, use your internet browser and search for “Telegram Web”. Login to your account on Telegram Web by scanning the QR code. 3.

How to get a chat ID of a telegram group?

How to get a Chat ID of a Telegram Group. Use the tool above to get the Chat ID of the group that your Bot is a member of. Create a Bot using the official telegram BotFather (it has a verified symbol next to it when you add it as a contact), Follow the prompts, and finally copy it’s HTTP API Token, Select the Bot User from the Group members list,

How do I get the chat ID of the group chat?

To get the chat ID of the group chat, use your internet browser and search for “Telegram Web”. Login to your account on Telegram Web by scanning the QR code. 3. Select the group chat that you have added your Telegram bot into, you will find the chat ID of the group chat shown in the URL within the address bar.

Why doesn’t my telegram chatbot automatically respond to me?

Once you’ve added your Telegram chatbot to your Telegram group, and you mention it, you will probably see that the chatbot doesn’t automatically respond: This is because the chatbot is not an admin of the group. So, you need to click on the top bar of your Telegram group:


1 Answers

In order to get the group chat id, do as follows:

  1. Add the Telegram BOT to the group.

  2. Get the list of updates for your BOT:

     https://api.telegram.org/bot<YourBOTToken>/getUpdates 

    Ex:

     https://api.telegram.org/bot123456789:jbd78sadvbdy63d37gda37bd8/getUpdates 
  3. Look for the "chat" object:

{"update_id":8393,"message":{"message_id":3,"from":{"id":7474,"first_name":"AAA"},"chat":{"id":<group_ID>,"title":""},"date":25497,"new_chat_participant":{"id":71,"first_name":"NAME","username":"YOUR_BOT_NAME"}}}

This is a sample of the response when you add your BOT into a group.

  1. Use the "id" of the "chat" object to send your messages.

  2. (If you created the new group with the bot and you only get {"ok":true,"result":[]}, remove and add the bot again to the group)

  3. Private chart only works in image argoprojlabs/argocd-notifications:v1.1.0 or above.

like image 86
Maverick_Java Avatar answered Sep 19 '22 16:09

Maverick_Java