How to Register a Telegram Bot

Navigate to your app and search for BotFarther

In the menu choose the first option “create a new bot”

Enter an arbitrary bot name and come up with a unique bot username. Right after that you’ve got a chat with your bot and API key

Now, you can send messages with your bot with a simple GET request to Telegram API. All you need is the token and chat ID.
The chat can be that private chat with the bot, or you can create a special one, up to you. Let’s assume we created a group and invited the bot to the chat.

We can check bot status with this API URL (replace XXXXXXXXXXXXXXXXXXXXXXX with your bot API KEY

https://api.telegram.org/botXXXXXXXXXXXXXXXXXXXXXXX/getUpdates

"ok": true is good, but we need chat ID. To get that, drop a message to the chat / group and update the page.

This is what you should see. Sometimes it happens that we don’t see an update immediately, you may try to remove / add bot one more time, execute some command, eventually, it will appear.

Okay, now we can send a message with the bot to the chat with this URL

https://api.telegram.org/botbotXXXXXXXXXXXXXXXXXXXXXXX/sendMessage?chat_id=-824859986&text=Hello

Replace there chat ID with your actual chat ID. Adding parse_mode=html parameter you can pass basic HTML inside the message.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *