Telegram notification script for Mikrotik

Simple script to send notifications to Telegram from Mikrotik

Sometimes the most simpliest thing could offer a lot of advantages.

To use this script you will need a Telegram Bot. It’s very simple and you dont need to do anything special to create yourself a bot. Here you will find all that you need to create your first bot.

To get the Chat ID you need to send a message to your bot to a group and access this address with your Bot Token:

https://api.telegram.org/bot<YourBOTToken>/getUpdates

You will see a JSON object… look for the CHAT object.

Now, let’s talk about the script…

You can just download this script into your files and use it to send all kind of notifications directly to you via Telegram or to some specific group.

This script is pretty simple. All you need to do is set a global variable with your Bot Token (provided by BotFather) and the another with your Chat ID. Every time that you call the script, you just need to a global variable with the message.

Here an example:

:set TelegramMessage "Here is my message"; /import "scripts/telegram.rsc"

Pretty simple right? Now imagine all kind of scenarios that you can use this… the sky’s the limit.

This script is on my GitLab, so you can copy as you will or donload it directly to your Mikrotik.

/tool fetch url=https://gitlab.com/rfranzen/mikrotik-scripts/raw/master/telegram-notifications.rsc dst-path=scripts/telegram.rsc

After use the script, you just need to set those two global variables:

:global TelegramBotToken
:global TelegramChatID

I hope this script could be useful for your projects.

 Share!

 
comments powered by Disqus