Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2020 11:10
What would you like to do?
To create a Telegram Bot
Step 1: Get a bot id and keys
Add botfather to your telegram account. Follow the interactive mode to choose the id, and you will get key (sample below, use your own key!).
Done! Congratulations on your new bot. You will find it at You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
Use this token to access the HTTP API:
Keep your token secure and store it safely, it can be used by anyone to control your bot.
For a description of the Bot API, see this page:
Step 2: Add your bot to the channel/group you want to use the bot in.
Assuming that you are the group admin, you can add the bot to the channel/group. Just search for the bot name (from the message above "sample_bot"), it is unique. And make sure you grant it admin rights, so it can send/receive messages.
Step 3: Run curl from commandline to get the channel/group id.
Send a few messages to your bot in the channel/group. Then run the following command.
curl -X POST ""
Now search through the JSON output and look for the message and note this part of the message:
chat":{"id":-1001292231786,"title":"<Your Channel/Group Name",...
In this case, the id of the group is -1001292231786
Step 4: Send yourself a message using the bot account now.
Run the following command:
curl -X POST "" -d "chat_id=-1001292231786&text=my sample text"
Done. Now you can write something cool with this. You can read and write from the channel/group now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment