How to obtain the chat_id of a private Telegram channel

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

Leave a Comment