Member-only story
Get Telegram Chat ID
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.
Instructions
- Install Telegram,
- 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,
- Create a Group,
- Add the Bot to it,
- Select the Bot User from the Group members list,
- Press the SEND MESSAGE button,
- Send the User a message.
- Retrieve the Chat ID from the chat data using the above tool.
The tool also show the returned JSON response. You can search the returned JSON data for last chat message with type=group or type=private and copy the chat id from this. This is your Chat ID to use for sending messages to the group.
Alternatively, If you don’t want to use the tool above, you can visit this URL. https://api.telegram.org/botXXX:YYYYY/getUpdates (replace the XXX: YYYYY with your BOT HTTP API Token you just got from the Telegram BotFather)
Troubleshooting
If the above tool doesn’t return a node containing a chat group with an id, then try sending another message with different text.
You can also try,
- removing your bot from the group,
- and then re adding your bot to the group,
- selecting it from the group members list,
- send it a new message,
- then try the
getUpdates
url again.
The source code for this tool can be found at https://codesandbox.io/s/get-telegram-chat-id-q3qkk