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?
Community
  • 1
  • 1
SkyN
  • 1,417
  • 4
  • 17
  • 32

4 Answers4

19

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

Saeed Heidarizarei
  • 8,406
  • 21
  • 60
  • 103
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!

njha
  • 1,118
  • 1
  • 13
  • 24
  • 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. – njha Mar 27 '16 at 22:29
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.

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.

Nakamoto
  • 1,293
  • 14
  • 17