Skip to content

Instantly share code, notes, and snippets.

@irokhes
Created September 26, 2021 18:50
Show Gist options
  • Save irokhes/de03e09e69a1746ce8140e90edeeef16 to your computer and use it in GitHub Desktop.
Save irokhes/de03e09e69a1746ce8140e90edeeef16 to your computer and use it in GitHub Desktop.
How to obtain the chat_id of a private Telegram channel
You should convert it to public with some @channelName
Send message to this channel through Bot API
https://api.telegram.org/bot111:222/sendMessage?chat_id=@channelName&text=123
bot+[yoour bot id]
As response you will get info 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"
}
}
Now you can convert Channel back to private (by deleting channel's link) and send message directly to this chat_id "-1001005582487"
https://api.telegram.org/bot111:222/sendMessage?chat_id=-1001005582487&text=123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment