Setup Telegram bot app
Register a bot
Chat with Telegram BotFather on Telegram app
Type this in your chat
/newbot
Then follow instruction from BotFather. When finished you will get bot_token which look like: [number]:[text]
Please keep it securely, if someone stole it, they can work like you.
Now, there are 2 common ways to work with your Bot.
- Register your webhook to receive chats from your users
Paste this url on your browser to register your webhook
https://api.telegram.org/bot{your_bot_token_above}/setWebhook?url=your_web_site_url
If Telegram responses with success, just go to your web and start code for your need. You can send message to user with a lot of useful formats.
2. Create group chat and send messages to group
Go to Telegram app, create new group chat and add your Bot (above) to the chat group.
Uhm, say ‘hi’ to your group.
Paste this url on your browser to receive group info
https://api.telegram.org/bot{your_bot_token_above}/getUpdates
You will have something as below
Find chat_id start with ‘-’, this is very important because you will send message to this chat_id.
Ok, let’s send message to group now.
From Terminal (MacOS, Linux)
curl -XPOST https://api.telegram.org/bot{your_bot_token_above}/sendMessage?chat_id={chat_id_above}&text=demo%20bot
Alternatively, you can use Postman to send message.
There are many message formats, follow Telegram document for more info.
https://core.telegram.org/bots/api#formatting-options
Ten articles before and after
How to send a message to your Telegram channel by Python? – Telegram 中文版
Track SSH Logins via Telegram. If you are a Dev-Ops Engineer, You and… – Telegram 中文版
data-rh=”true”>新手指南(3)—玩 Airdrop (空投)事前準備,15分鐘搞掂開始賺幣 – KK教玩幣 – Medium – Telegram 中文版
Домашняя бухгалтерия в telegram. Отложенные счета. – Telegram 中文版
Tasker and Telegram integration: live location – Telegram 中文版
How to write UK Rent Telegram Bot – Telegram 中文版
Домашняя бухгалтерия в telegram. Электронные чеки. QR. – Telegram 中文版
Example of a telegram bot in python without using specific libraries – Telegram 中文版
Monitorar suas aplicações na AWS usando o Telegram – Telegram 中文版