How to get the right telegram channel id?
Asked Answered
L

4

13
  • If I get user_id, by contacts.resolveUsername#bf0131c and search by string channel, then I get user_id = 0x0827ac18

If send it to messages.getFullChat#3b831c66, then receive error PEER_ID_INVALID.

If send if to users.getFullUser#ca30a5b1, then I get error USER_ID_INVALID.

  • If I search string channel using contacts.search#11f812d8, then I get two user with username ChannelBot and Channel_Bot, but not get with user or channel name channel.

  1. How get channel id for using in messages.getFullChat#3b831c66?
  2. How get chat_id by name?
Longsighted answered 19/3, 2016 at 8:46 Comment(2)
what library are you using to work with telegram API?Gilbertegilbertian
github.com/sochix/TLSharpLongsighted
F
19

Just Simply Forward a message from your channel to This Bot: (https://telegram.me/getidsbot)

Florindaflorine answered 8/8, 2017 at 20:37 Comment(2)
NOTICE My channel id starts with '-'Crissycrist
This bot is currently down. But there is an alternative. Check my answer bellow: https://mcmap.net/q/850525/-how-to-get-the-right-telegram-channel-idCortisone
G
10

How to get the chat_id for a private channel:

Make it public, give it an @ChannelName Send message to this channel through your bot API or cURL

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

It will return the channel id!

{ "ok" : true, "result" : { "chat" : { "id" : -?????????, "title" : "Test Private Channel", "type" : "channel" }, "date" : X, "message_id" : 7, "text" : "XXXXXX" } }

Now you can convert the channel to private and use the chat_id!

Gravante answered 27/3, 2016 at 22:29 Comment(1)
This doesn't use the API, but it works. It also works for public channels, just skip the parts about making it public and then private again.Gravante
M
1

The Telegram API Supports this directly. https://core.telegram.org/bots/api#available-methods. Look at method getChat

  1. Convert Your channel to a public channel and create a temporarily memorable name like 'TestChannel123_temp'
  2. Run the following cmdlet (powershell)

    PS C:\Users\Me> Invoke-RestMethod -Method Get -Uri "https://api.telegram.org/botTOKEN_HERE/getChat?chat_id=@publicId"
    
      ok result
      -- ------
    True @{id=-YOUR_CHAT_ID; title=YOUR_CHAT_TITLE; username=YOUR_CHAT_USERNAME; type=supergroup; photo=}
    
    
    PS C:\Users\Me>
    
  3. Convert group back to private.

  4. Send messages via know chat Id.

Mecklenburg answered 6/7, 2018 at 21:2 Comment(0)
C
1

Telegram Channel ID from @JsonDumpBot

You can simply forward a message to @JsonDumpBot.

The bot dumps a complete json of all request that he receives.

NOTE: I'm not affiliate and it's not my bot.

Cortisone answered 28/1, 2021 at 23:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.