Sending a Message using Telegram API in 3 Steps
Using Bot API
Today, we will learn some simple steps to send a message to a telegram channel using the Bot API. We just need a Telegram account. Click here if you don’t have one.
Step 1: Create a Telegram BOT
- Create a Telegram BOT via BotFather
- Click here or search for the username “@botfather” in Telegram and click on it to start the chat.
- Then, click on the START button at the bottom of the chat.
- Send the following commands in your chat:
It will show you a lot of options. Then type:
Now it will ask you to choose the name of your bot. For example type:
Blog Post Ideas
Now it will ask you to choose a username for your bot.
But, it should end with _bot suffix. For example type:
Now, your bot is ready. It will return you an HTTP API value which looks something like the below value:
Note: Do not share this value with anyone because it can be used to control your bot.
Step 2: You must have a Telegram Channel
- Create a Telegram public channel
- Open Telegram on your mobile, and click on New Channel option from the menu.
- Then give your channel a name. For example “Blog Post Ideas”
- Choose a username for your channel. For example “blogposteideas”
- Add any single contact of one of your family or friends to your channel.
Step 3: Add your BOT to your Telegram Channel
- Open your channel details and click on Administrators option.
- Then click on Add Admin and search for your bot username and add it.
That’s it. You are ready to send your first message via Bot API. Copy the below the HTTP GET request and replace BOT API KEY, CHANNEL USERNAME & MESSAGE TEXT with your values:
https://api.telegram.org/bot[BOT API KEY]/sendMessage?chat_id=[CHANNEL USERNAME]&text=[MESSAGE TEXT]
You can use any browser to test it. Just paste this in the URL section.
That’s all folks. Thanks for reading, I hope it was simple and easy to understand for everyone.
Making the world a better place.