How to obtain the chat_id of a private Telegram channel?

The easiest way:

Just send your invite link to your private channel to @username_to_id_bot (https://t.me/username_to_id_bot) bot. It will return its ID. The simplest level: maximum! :)

PS. I am not an owner of this bot.

PS 2. the Bot will not join your group, but to be sure in security. Just revoke your old invitation link if it is matter for you after bot using.

A more cumbersome way:

Making the channel public cannot be done by the user with exist at least five public groups/channels, so...the problem is not solved. Yes, you can revoke one of them, but for now, we cannot retrieve chat id another way.

Revoke

A crazy solution:

  1. log in under your account at web version of Telegram: https://web.telegram.org
  2. Find your channel. See to your URL. It should be like https://web.telegram.org/#/im?p=c**1055587116**_11052224402541910257
  3. Grab "1055587116" from it, and add "-100" as a prefix.

So... your channel id will be "-1001055587116". Magic happens :)

The solution was found at Web Channel ID .


I found the way to write in private channels.

  1. You should convert it to public with some @channelName

  2. Send a message to this channel through the Bot API:

    https://api.telegram.org/bot111:222/sendMessage?chat_id=@channelName&text=123

  3. As the response, you will get information with chat_id of your channel.

    {
      "ok" : true,
      "result" : {
        "chat" : {
          **"id" : -1001005582487,**
          "title" : "Test Private Channel",
          "type" : "channel"
        },
        "date" : 1448245538,
        "message_id" : 7,
        "text" : "123ds"
      }
    }
    
  4. Now you can convert the channel back to private (by deleting the channel's link) and send a message directly to the chat_id "-1001005582487":

    https://api.telegram.org/bot111:222/sendMessage?chat_id=-1001005582487&text=123

Tags:

Telegram Bot