How to get the right telegram channel id?

Viewed 28624
  • 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?
4 Answers

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.

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.

Related