Telegram

Hotspot On-Logout Telegram Notification — 7

Put it in a hotspot user profile's On Logout field. Every logout sends a Telegram message with the voucher name, IP address and the reason the session ended.

MikroTik Version

RouterOS 7

# EN: Telegram bot token from @BotFather | AR: توكن البوت من @BotFather
:local botToken "change here";
# EN: Telegram chat ID that receives the alerts | AR: رقم الشات الذي سيستقبل التنبيهات
:local chatId "change here";

# EN: Runs only after the two variables are edited | AR: لا يعمل إلا بعد تعديل المتغيرين
:if ($botToken != "change here" && $chatId != "change here") do={
    # EN: $user, $address and $cause are provided by the hotspot at logout | AR: المتغيرات $user و $address و $cause يوفرها الهوتسبوت عند الخروج
    :local nl "%0A";
    :local text ("LOGOUT" . $nl . "Voucher:+" . $user . $nl . "IP:+" . $address . $nl . "Reason:+" . $cause);
    /tool fetch url=("<https://api.telegram.org/bot>" . $botToken . "/sendMessage?chat_id=" . $chatId . "&text=" . $text) keep-result=no;
}