3

How to get Telegram Bot Super Group ID?

With This Code:

bot.on('message', (msg) => {
  console.log(msg);
});

I Can See my Private Channel ID in forward_from_chat: { id: -1001125265425, of the object, That is Okey.
But How Can I Get Super Group ID?

Saeed Heidarizarei
  • 8,406
  • 21
  • 60
  • 103

1 Answers1

4

First of all, you should add a bot to that group.

Then if the group is public (has @username), just send message to the group and read reply from Telegram server, it will be of type Message, and Message->Chat->Id is group's ID.

If the group is private (doesn't have a @username), then you can mention a bot in your message and, again, read reply from Telegram server.

Or you can use some third-party bots, for example, @my_id_bot, which I made specifically for this.

Groosha
  • 2,897
  • 2
  • 22
  • 38
  • @my_id_bot did the trick for me, just add it and send a message like /getid. thks – rodrigorf Apr 15 '20 at 01:16
  • Hey, @rodrigorf, I'm that bot's creator and for supergroups you can just add the bot to the group to get its ID. Did you have to ping him explicitly? – Groosha Apr 15 '20 at 20:37
  • Hey @Groosha, that's exactly what i did. I added the bot to the group, but i had to run the command /geid@myidbot to show the number – rodrigorf Apr 16 '20 at 02:03
  • ops, my mistake, i have run: /getgroupid@myidbot – rodrigorf Apr 16 '20 at 02:04