short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.
Post Reply
Dominikat
Posts: 1
Joined: Monday 20 June 2016 16:15
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Austria
Contact:

short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Post by Dominikat » Monday 20 June 2016 17:02

Hello, since i was asked by a friend how to use Telegram Bots for notifications i wanted to write a short Tutorial (a fast search didn't show one on this forum).

Since Telegram introduced Bots there is a simple way to tell Domoticz to send your Notifications to your Telegram-Account. You have to start a new Bot, start a chat and tell Domoticz to send the notifications to this chat. You can't control Domoticz via Telegram with this method, but you can get Notifications.
  1. Install Telegram
  2. start a chat with BotFather. He will show you a message beginning with "They call me the Botfather....."
  3. tell Botfather "/newbot"
  4. write the name of your bot and hit Enter
  5. Now give your bot a username. it must end with "bot". Simply write it and type Enter
  6. Now you get an address for you bot and - important!- an access token.
  7. Start a Chat with your new Bot identified by the username you gave him.
  8. type /start Enter
  9. tell the bot "Hello World" or something similar, the message does not matter.
  10. in your Browser open the address https://api.telegram.org/bot<yourBotToken>/getUpdates
  11. now you get a message back in your browser (a webpage opens). There is a part "{"id":<YourChatId,"first_name":...." Notice the chatId
  12. got to your Domoticz Page => Setup => Settings => Notifications. on the right you will find "Custom HTTP / Action"
  13. Click "Enabled"
  14. in the field "URL/Action" enter https://api.telegram.org/bot<YourBotApi ... t=#MESSAGE.
    For <YourBotApi> enter the API Key BotFather told you during Bot creation, for <YourChatId> your Chatid.
  15. Hit "Test" and you should get the Domoticz Test Message
If you want your notifications to be delivered to more people simply add them to the chat.

If you want a specific Userpic for the bot, e.g. the Domoticz Logo, you can tell BotFather "/setuserpic", then pic your Bot from the list and upload a profile pic.

That's it, have fun!

simonrg
Posts: 1071
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi
Domoticz version: 3.8807
Location: North East England
Contact:

Re: short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Post by simonrg » Monday 20 June 2016 22:15

Have you had a look at the Domoticz wiki?

http://www.domoticz.com/wiki/Telegram_Bot
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266

User avatar
Derik
Posts: 2185
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Post by Derik » Sunday 26 June 2016 19:58

Dear Dominikat,
I try your "wiki"...
Only i have in my browser a new Bot. [ Test ]
See the bot:
ScreenShot055.jpg
ScreenShot055.jpg (40.74 KiB) Viewed 4976 times
I cannot get/set a username ..
And i cannot find the bot in my windowsphone... app

Please some prints..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups

niki_lauda
Posts: 142
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Post by niki_lauda » Sunday 09 September 2018 15:51

Dominikat wrote:
Monday 20 June 2016 17:02
Hello, ...........
If you want your notifications to be delivered to more people simply add them to the chat.
How do you add someone to a chat??

Plantje
Posts: 172
Joined: Friday 16 October 2015 7:58
Target OS: Windows
Domoticz version:
Contact:

Re: short Tutorial: Telegram Bot for notifications via HTTP (no Lua/Script/...)

Post by Plantje » Thursday 13 September 2018 16:57

Thank you for this brief tutorial! Agreed with other comments... everything can be found in the Wiki, but this is nice and clean!

Curious to know how to add more users as well!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests