How can we help?
< All Topics
Print

How to send Telegram Notification?

Anatomy of the Telegram sendMessage API

Sample URL:

https://api.telegram.org/bot1115233676:AAGGvBlnPI7xxxxxxxxxxxxxxxxxxxxxx/sendMessage?chat_id=12345678&text=Hello%20How%201%20are%20you

The URL has 5 segments:

  1. Base URL – https://api.telegram.org/
    • This part of URL stays the same always
  2. Bot Token – “bot1115233676:AAGGvBlnPI7xxxxxxxxxxxxxxxxxxxxxx”
    • Every telegram bot has a unique Bot identification Id
  3. Method – “sendMessage”
    • The method used for sending text messages is sendMessage. There are other methods to send image, audio, video or location..
  4. 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.
  5. 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:

  1. Bot ID – We share botbaba’s telegram bot id with only our “done-for-you” users.
  2. Chat ID – We will guide you how to obtain a chat id.
  3. 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 example
https://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.

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Previous How to use Conditional Jump?
Next How to use your Gmail account to send emails from botbaba?
Table of Contents