javascripttelegram-botnode-telegram-bot-api

How to get Telegram Bot Super Group ID?


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?


Solution

  • 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.