How to send Telegram Notification?
Anatomy of the Telegram sendMessage API
Sample URL:
The URL has 5 segments:
- Base URL – https://api.telegram.org/
- This part of URL stays the same always
- Bot Token – “bot1115233676:AAGGvBlnPI7xxxxxxxxxxxxxxxxxxxxxx”
- Every telegram bot has a unique Bot identification Id
- Method – “sendMessage”
- The method used for sending text messages is sendMessage. There are other methods to send image, audio, video or location..
- Chat ID – “12345678”
- This is a unique chat ID of a particular person/group in Telegram. This will help system to send message to a specific chat person/group in Telegram. Steps to get this Chat ID will be explained later in this article.
- Message – Hello, How are you?
- You can write the content of the message in this query parameter. It should be URL Encoded. (Use this tool for URL Encoding a piece of text – https://urlencoder.org)
We basically need 3 things to send a telegram message:
- Bot ID – We share botbaba’s telegram bot id with only our “done-for-you” users.
- Chat ID – We will guide you how to obtain a chat id.
- Message – Thats pretty obvious.
How to obtain Group Chat ID?
Create a group on Telegram. Add your bot in the group (as it will send the messages.)
Now, you can get update of what so ever conversation is done in the group through this URL. This URL contains 3 parts: Base URL + Bot Identification + “getUpdates”
So, the URL will look like,https://api.telegram.org/bot1115233676:AAGGvBlnPI7xxxxxxxxxxxxxxxxxxxxxx/getUpdates
Now, you will see a screen like this
Install a Chrome Extension called ‘Json Formatter’ to view the json in a readable format like above.
Now, you need to look for 2 words, i.e., “chat” and “id”
So, our Chat Id in this example is “-333442209”
Groups will have a ‘-‘ (hyphen/minus sign) prefixed to it.
Individual Chats will only have a number.
How to send message in the group?
Very first step to this process is to enable HTTP-Request in a block (just like shown in the below screenshot)
Now you can copy-paste the URL which we created in the previous examplehttps://api.telegram.org/bot1115233676:AAGGvBlnPI7xxxxxxxxxxxxxxxxxxxxxx/sendMessage?chat_id=-333442209&text=Hello%20How%201%20are%20you
Async Call:
If you enable Async call, then it means that your bot will wait for the response from the api (success/failure) and then move to the next message in the conversation. You can check it on/off at your own discretion.