Set of scripts to forward SMS messages to Telegram for Mikrotik
Tested on Mikrotik LGH LTE6 Kit
- Works directly with modem
- Supports UCS2 (non-ASCII) messages
- Create a telegram bot using @botfather
- Get chat id or group id using https://api.telegram.org/botXXX:YYYY/getUpdates
- Fill in bot token and chat id in
tgbot-notify.rsc
- Save all 3 scripts on your mikrotik device
tgbot_notify_robot
:/system script run tgbot_notify.rsc
at startup, interval1m
tgbot_smsfwd_robot
:/system script run tgbot-smsfwd.rsc
at startup, interval3m
tgbot_notify_startup
:/system script run tgbot-startup.rsc
at startup once
- Disable SMS processing
/tool sms set receive-enabled=no auto-erase=no
- Messages queued to send are stored in
TGBOTMQ
array of messages. Each message is array with mandatoryMessage(str)
field andSent(str)
fields and any optional fields. tgbot_notify_robot
task runs every minute. It looks for globalTGBOTMQ
array of messages for messages withSent = "no"
. It rties to send message, and if message is sent OK, message'sSent
is set toyes
tgbot_smsfwd_robot
task runs every 3 minutes. It looks for SMS stored in SIM card, decodes them into text format and puts intoTGBOTMQ
array. Messages withSent
=yes
are removed from bothTGBOTMQ
and SIM card.tgbot_notify_startup
task runs at startup, waits for NTP time to be synced and sends message with boot event toTGBOTMQ