Dude Telegram notification example

Currently it’s not possible to use HTTP POST method from Dude/RouterOS, so here is some workaround example how to use Telegram, to send messages using HTTP GET method:

http://wiki.mikrotik.com/wiki/Manual:The_Dude_v6/Dude_Telegram_Example

Suggestions / requests will be appreciated.

That’s a great solution… I’m having trouble though - I can run the /tool fetch command from the command line and it works fine, but nothing happens when I run it from The Dude. I’ve tried pressing Test, and I’ve tried unplugging a router to see what happens, and the command never executes. Can’t see anything in the logs. Any ideas?

Never mind, just noticed this:
Changes in v6.39rc7:

*) Fixed - Tool fetch didn’t work with notification - execute on server

Upgrading now

OR

:execute {/tool fetch url="https://api.telegram.org/botXXXXXX:AsG7sapGXDS1aHi_RllzgU9oJUm2wyKyHVw/sendMessage\?chat_id=1231231&text=[TimeAndDate] Service [Probe.Name] on [Device.Name] ([Device.CustomField1] - [Device.CustomField2]) is now [Service.Status] ([Service.ProblemDescription])" keep-result=no}

this option works for older versions

I configured all and is working!!!

Correct code for Version 6.38.1 - Please update de wiki

 /tool fetch url="https://api.telegram.org/botXXXXXXX:AAFZJtaHT_of7tV9IPEyK9R9XXXXFtk9_Ap-Pvk/sendMessage\?chat_id=XXXXXX&text=[TimeAndDate] Nodo: [Device.Name], Status: [Service.Status]" keep-result=no

Gretting

Pablo
Sorry for my bad English

Hi,

what should be the chat_id= ??

thanks

after creating the bot you can write to him. from browser you can see the id of this chat (you can use https://api.telegram.org/botXXXXXXXXXXXXXXXXXX/getUpdates )
You should find “«chat»:{«id»:YYYYYYY”
YYYYYYY - is your chat_id

thank you verymuch… its work. I would like to ask another question, is possible to do this on viber also ?

Thanks.

yes you can. +37544five44340five

What’s the problem in settings .

Hi,

I’ve tested the hyperlink, that it’s inside the fetch command:

https://api.telegram.org/bot123456789:AAQFb1byb3LEwMes_TQeCM1k5wsFb_VguhG/sendMessage\?chat_id=123456789&text=Hello

But It doesn’t even send the Hello message to the group the bot is participating.

The webpage says: “{“ok”:false,“error_code”:404,“description”:“Not Found: method not found”}”

In Mikrotik terminal, it says: failure: closing connection: <400 Bad Request> 149.154.167.200:443 (4)

Am I doing something wrong? Do I need any additional step to allow the bot start a message?

Thanks! :confused:

What do you think of adapting the dude to send messages through Whatsapp it is much more popular than the telegran.

or viber…

You can do the same with Viber. Use a Viber “Public Account”. I haven’t tried yet as it’s only available for selected countries.

Telegram is so far the easiest and most accessible.



/tool fetch url="https://api.telegram.org/botxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/sendmessage?chat_id=xxxxxx&text=Hi" keep-result=no
/tool fetch url="https://api.telegram.org/bot<tokenbot>?chat_id=-1001099321185&text=[RECOVER] [TimeAndDate]; [Device.Name]: [Device.FirstAddress]; Status: [Service.Status] ([Service.ProblemDescription])" keep-result=no

for me this work… in my situation i’ve created a channel with other my coworker…this is a great solution for notification, very reactive!
and then you can evolute your bot with some scripts, notification db ecc.ecc.
great thing

HI
issue fixed??

The issue was fixed, adding a minus sign before the chat ID:

before:

https://api.telegram.org/bot123456789:AAQFb1byb3LEwMes_TQeCM1k5wsFb_VguhG/sendMessage\?chat_id=123456789&text=Hello

after:

https://api.telegram.org/bot123456789:AAQFb1byb3LEwMes_TQeCM1k5wsFb_VguhG/sendMessage\?chat_id=-123456789&text=Hello

:slight_smile:

remove \ from “sendMessage?chat_id=”

hi
how to send file ( backup file ) via Telegram ?