Good afternoon, I was finally able to make sending messages to a Telegram channel or group work. This allows receiving alerts to a Telegram group or channel through OR rules.
The procedure would be the following:
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:
/start
It will show you a lot of options. Then type:
/newbot
Now it will ask you to choose the name of your bot. For example type:
Alarms 1 Open Remote
Now it will ask you to choose a username for your bot.
But, it should end with _bot suffix. For example type:
oralarm1_bot
Now, your bot is ready. It will return you an HTTP API value which looks something like the below value:
1234567890:AAAAxY6udNO5u-9fO793yFdZaL1qU2RIkGT
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 “Alarms 1”
Choose a username for your channel. For example “usealarms”
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=[ID CHANNEL]&text=[MESSAGE TEXT]
The command to get the channel ID
https://api.telegram.org/bot1234567890:AAAAxY6udNO5u-9fO793yFdZaL1qU2RIkGT/getUpdates
“my_chat_member”:{“chat”:{“id”:-100180168898,“title”:“Alarms 1”,“type”:“channel”},“from”:
You can use any browser to test it. Just paste this in the URL section.
https://api.telegram.org/bot1234567890:AAAAxY6udNO5u-9fO793yFdZaL1qU2RIkGT/sendMessage?chat_id=-100180168898&text=high%20power%20consumption%20alarm
Now we can use that link in the “WEB URL” of the OR When-Then Rules webhook. The text to send must be modified according to what you want to alert. For now I did not find the way to use the Body in the request.