So to perform any action with your bot you need to have created one: https://techimposter.co/posts/telegram-create-a-telegram-bot

When you complete the process, botfather will give you a token. Keep this one safe.

Now in order to get the channelId for a channel that your bot is in, let's add the bot to a channel/group. Your bot should now be one of the members of the group.

  1. Send one or two test messages in the group after you have added the bot
  2. Visit this url: https://api.telegram.org/bot/getUpdatesbut replace the YourBotToken part with your bot's actual token (the one from botfather, for example something like - 5823039815:AAHXXXXXXXXXXXXXXXXXXXXX)

If you are lucky, that should be it. But in some cases you might see this:

{ "ok": true, "result": [] }

If you do, then:

  1. Remove the bot from the group (you might notice, it says something like has no access to messages)
  2. Add it again
  3. Visit that link (the one with your token) again

Look for the object labelled chat:

"chat": { "id": -911111111, "title": "Group name", "type": "group", "all_members_are_administrators": false }

The ID part is what we are looking for.

Sorted!

More Stories, Tips and tricks
Solving the Gradle Error: 'Failed to calculate the value of task' in Flutter
Stuck with a persistent Gradle error in your Flutter project? Discover a quick fix for the 'Failed to calculate the value of task' error and get your project back on track.
Read more
Google Play Developer: Target SDK API Level 33 Deadline
Unlock Success: Google Play Developer Deadline Secrets Revealed! Don't miss out on crucial insights
Read more
Telegram: Get a channel Id from Telegram
Working with a Telegram bot is awesome. Here are some pointers.
Read more