Page 1 of 1
How to make Telegram notifications work?
Posted: Thursday 17 May 2018 10:12
by tgg3
I'm trying to get Telegram notifications working. However, I see the following in the log when I click the "Test" button next to to the Telegram notification settings:
---------------
2018-05-17 16:02:43.737 Error: Telegram: {"ok":false,"error_code":404,"description":"Not Found"}
2018-05-17 16:02:43.737 Notification sent (telegram) => Failed
2018-05-17 16:02:43.753 Active notification Subsystems: telegram (1/14)
---------------
I got the API Key and the Chat ID (from the @get_id_bot on Telegram) and pasted those strings into the notification settings Telegram. I get the feeling I need to do something else.
Thanks much for your help.
Re: How to make Telegram notifications work?
Posted: Thursday 17 May 2018 16:53
by simonrg
The error looks like it isn't Domoticz, but somehow in the communication to / from Telegram.
Try this is browser -
Code: Select all
http://api.telegram.org/botAPInumeric:APIalphanumeric/sendMessage?chat_id=CHATID&text=Hello
Replace APInumeric:APIalphanumeric with your API key and CHATID with your chat ID.
Response should be:
Code: Select all
{"ok":true,"result":{"message_id":xxxxxx,"from":{"id":xxxxxxx,"is_bot":true,"first_name":"Bot Name","username":"botname"},"chat":{"id":xxxxxxx,"first_name":"firstname","last_name":"surname","username":"userid","type":"private"},"date":1526568064,"text":"Hello"}}
Are you able to get this to work?
Re: How to make Telegram notifications work?
Posted: Friday 18 May 2018 6:51
by tgg3
I found my problems. Your HTTP test code was very useful. I hadn't created the bot and then added a chat for that bot to my Telegram app (which isn't mentioned in
https://www.domoticz.com/wiki/Telegram_notification). The api key I was using didn't go with the bot I ended up creating.
Sorry for the NOOB mistake. There are so many new concepts for someone new to the world of DIY IoT (sensors, controllers, new hardware, new software languages, messaging APIs, etc.). I really appreciate the help from everyone in the support forums.
Re: How to make Telegram notifications work?
Posted: Thursday 21 February 2019 0:09
by WarLion
i had a problem like this if i use the URL
https://api.telegram.org/bot*****:***** ... &text=test
work prefect
but when i use my token and chat_id on domoticz notificacion (latest beta) i get
2019-02-20 17:05:30.535 Error: Telegram: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}
also using it on custom HTTP/action works without a problem
Re: How to make Telegram notifications work?
Posted: Thursday 21 February 2019 8:19
by jvdz
Did you fill in the token without the "bot" prefix?
Jos
Re: How to make Telegram notifications work?
Posted: Thursday 21 February 2019 16:02
by WarLion
i did just the token , , i decide to try again and now is working didnt change anything , not sure why yesterday didnt work, thanks guys
Re: How to make Telegram notifications work?
Posted: Sunday 03 March 2019 11:00
by Marque1968
tgg3 wrote: ↑Friday 18 May 2018 6:51
I found my problems. Your HTTP test code was very useful. I hadn't created the bot and then added a chat for that bot to my Telegram app (which isn't mentioned in
https://www.domoticz.com/wiki/Telegram_notification). The api key I was using didn't go with the bot I ended up creating.
Sorry for the NOOB mistake. There are so many new concepts for someone new to the world of DIY IoT (sensors, controllers, new hardware, new software languages, messaging APIs, etc.). I really appreciate the help from everyone in the support forums.
So how did you add the chat to your telegram app. Also a noob on this end, who installed Telegram soley for this purpose...
Re: How to make Telegram notifications work?
Posted: Monday 04 March 2019 8:16
by Marque1968
Ok, for the noobs that didn't get it either:
- In Telegram select Menu
- Select contacts
- Press the add-button
- enter @ + the name you have entered upon creating the key.
Only now you will recieve the bot messages.
Re: How to make Telegram notifications work?
Posted: Friday 12 April 2019 20:38
by pretendor
Guy's i have all things done.
the api HTTP access link will sent me a notification.
so the token and the chatid er fine.
still got the same error message in domoticz.
2019-04-12 20:32:42.237 Notification sent (telegram) => Failed
2019-04-12 20:32:42.244 Active notification Subsystems: email, pushbullet, telegram (3/13)
2019-04-12 20:32:42.237 Error: Telegram: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}
any idea how to fix?
if i use the link:
http://api.telegram.org/bot*******:**** ... text=Hello
on privacy reasons changed the values to ***.
i got the replay that everything is ok and get a new message in telegram (on the bot channel i created) so the bot is working fine and the apitoken and chat_id also......... need help cuz this time i'm gonna crazy!
Re: How to make Telegram notifications work?
Posted: Friday 12 April 2019 21:57
by jvdz
You need the Chat_id, not a channel_id for this to work.
try sending it to your telephone's chat_id.
Jos
Re: How to make Telegram notifications work?
Posted: Friday 12 April 2019 22:11
by pretendor
jvdz wrote: ↑Friday 12 April 2019 21:57
You need the Chat_id, not a channel_id for this to work.
try sending it to your telephone's chat_id.
Jos
Jos i had used the chat id that i requested by the @get_id bot
Re: How to make Telegram notifications work?
Posted: Friday 10 April 2020 17:39
by gschmidt
jvdz wrote: ↑Friday 12 April 2019 21:57
You need the Chat_id, not a channel_id for this to work.
try sending it to your telephone's chat_id.
Jos
Hey Jos,
I have telegram notification working when using my telephones chat_id, but is it also possible to push domoticz notifications to my 2 other family members?
Re: How to make Telegram notifications work?
Posted: Friday 10 April 2020 18:42
by jvdz
You could setup either a group or a channel in Telegram when you want to address multiple people with the buildin Telegram notification.
I use for my own notifications a lua script that sends the Telegram Bot notifications, where I can select to whom it needs to be send to and control the number of people easily.
Jos
Edit: Something like this LUA function will submit 1 or 2 notifications depending on the name you provide in the function call:
Code: Select all
function TelegramMsg(sendto, message)
token = "123456789:xxxxxxxxxxxxxxxxxxxxxxxxxx"
ID1 = 1111111
ID2 = 2222222
NAME1 = "name1"
NAME2 = "name2"
ALL = "both"
-- Define sending text without notification
if (sendto == ALL or sendto == NAME1 or sendto == ID1) then
os.execute('curl --data chat_id='..ID1..' --data-urlencode "text='..message..'" '..' "https://api.telegram.org/bot'..token..'/sendMessage" &')
end
if (sendto == ALL or sendto == NAME2 or sendto == ID2) then
os.execute('curl --data chat_id='..ID2..' --data-urlencode "text='..message..'" '..' "https://api.telegram.org/bot'..token..'/sendMessage" &')
end
end
Code: Select all
TelegramMsg("name1", "Send Telegram notification to person 1")
TelegramMsg("name2", "Send Telegram notification to person 2")
TelegramMsg("both", "Send Telegram notification to both persons")
Re: How to make Telegram notifications work?
Posted: Sunday 06 September 2020 20:18
by riko
jvdz wrote: ↑Friday 10 April 2020 18:42
You could setup either a group or a channel in Telegram when you want to address multiple people with the buildin Telegram notification.
I use for my own notifications a lua script that sends the Telegram Bot notifications, where I can select to whom it needs to be send to and control the number of people easily.
Jos
Edit: Something like this LUA function will submit 1 or 2 notifications depending on the name you provide in the function call:
Code: Select all
TelegramMsg("name1", "Send Telegram notification to person 1")
TelegramMsg("name2", "Send Telegram notification to person 2")
TelegramMsg("both", "Send Telegram notification to both persons")
Nice solution which I would like to use. I'm only thinking how to handle the notifications which I've configured today on switches in the Domoticz interface (by clicking the 'notifications' button). Is there a way how I can use this script in an easy way on these switches? Instead of writing separate scripts for it.
Re: How to make Telegram notifications work?
Posted: Sunday 06 September 2020 20:53
by jvdz
The group/channel solution will obviously also work with the standard build-in notification mechanism.
I am not sure whether a DzEvents script can be triggered on an Notification, but don't think regular LUA events can do that, so I have all my event notifications programmed in my scripts.
Re: How to make Telegram notifications work?
Posted: Thursday 08 February 2024 11:37
by rfvdboom
At first my telegram notification wasnt working in Domoticz after using the turorial in the Wiki. Got Error in de log. After some testing i found out that my ad-blocker was blocking the API request from Telegram. So make sure you whitelist the API request from telegram in your Adblocker.
