2.6 KiB
Forward received SMS
ℹ️ Info: This script can not be used on its own but requires the base installation. See main README for details.
Description
RouterOS can receive SMS. This script forwards SMS as notification.
A broadband interface with SMS support is required.
Sample notification
Requirements and installation
Just install the script:
$ScriptInstallUpdate sms-forward;
... and add a scheduler to run it periodically:
/system/scheduler/add interval=2m name=sms-forward on-event="/system/script/run sms-forward;" start-time=startup;
Configuration
Notification settings are required for e-mail, matrix and/or telegram. Also you have to enable receiving of SMS:
/tool/sms/set receive-enabled=yes;
The configuration goes to global-config-overlay, this is the only parameter:
-
SmsForwardHooks: an array with pre-defined actions in form where the key of the array is the regular expression to match the SMS text and the value is the action to execute::global SmsForwardHooks { { match="command"; allowed-number="1234"; command=":put "command executed"" }; # add more here... };in this example the command
:put "command executed"will be executed when a SMS with text starting withcommandis received from number1234.Useful use case is to send an SMS to order an additional internet package when the current one is about to deplete, and the automatic SMS is sent from the provider with the text that 80%, 100% of the package are used. Then, an automated SMS can be sent to a provider back to order a new package automatically. For example, for the KPN provider, the SMS text is
NL2000 AANsent to number1266to order an additional 2GB package. Then, the following configuration can be used::global SmsForwardHooks { { match="80%"; allowed-number="KPN"; command="/tool/sms/send lte1 phone-number=1266 message=\"NL2000 AAN\";" }; };This reads as: when the SMS with text
80%is received from numberKPN, the SMS with textNL2000 AANis sent to the provider. If you use unlimited plan, this is exactly what you need to do to order a new package automatically.
