Send telegram messages from Mikrotik RouterOS

If you are here you probably already know what telegram is. If not you can read about it here.

I created a simple script (SendToTelegram) that allows you to send messages to telegram:

:global telegramMessage
:local botid
:local chatid

set botid "sdfzgasf7126jwsd7a8s12>" # <- change this
set chatid "21156423187"            # <- change this

if ($telegramMessage != "") do={
   /tool fetch url="$botid/sendMessage\?chat_id=$chatid&text=$telegramMessage" keep-result=no
   set telegramMessage ""


set your message to telegramMessage global variable

global telegramMessage "Wolfy was here"

run script

/system script run SendToTelegram

You can use this in combination with netwach:

you should recieve a message to your telegram :)

(3) Comments

  • Mario
    18 Mar 2020

    Hi, I try but don’t work

    • Uroš
      18 Mar 2020

      Hi Mario,

      in one of the RouterOS system updates they disabled the option to change global variables.

      One possible solution is to create one script per message and call that “hardcoded” script.

  • Otgoo
    19 Apr 2021

    Thank you. This is useful script. Maybe we can use file or other unused configuration parameter to exchange messages instead of global variable. E.g. firewall address list, dummy dns static record or just dummy any config with comment parameter anywhere.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.