2020-03-27 21:50:27 +01:00
Forward received SMS
====================
2024-03-06 14:30:19 +01:00
[](https://github.com/eworm-de/routeros-scripts/stargazers)
[](https://github.com/eworm-de/routeros-scripts/network)
[](https://github.com/eworm-de/routeros-scripts/watchers)
2025-02-07 17:39:48 +01:00
[](https://mikrotik.com/download/changelogs/)
2024-03-06 14:30:19 +01:00
[](https://t.me/routeros_scripts)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick& hosted_button_id=A4ZXBD6YS2W8J)
2023-01-10 14:45:27 +01:00
[⬅️ Go back to main README ](../README.md )
2020-03-27 21:50:27 +01:00
2022-02-12 13:05:56 +01:00
> ℹ ️ **Info**: This script can not be used on its own but requires the base
2022-02-11 23:34:39 +01:00
> installation. See [main README](../README.md) for details.
2021-05-03 15:07:50 +02:00
2020-03-27 21:50:27 +01:00
Description
-----------
RouterOS can receive SMS. This script forwards SMS as notification.
A broadband interface with SMS support is required.
2021-06-17 15:23:51 +02:00
### Sample notification
2022-10-20 10:58:48 +02:00

2021-06-17 15:23:51 +02:00
2020-03-27 21:50:27 +01:00
Requirements and installation
-----------------------------
Just install the script:
$ScriptInstallUpdate sms-forward;
... and add a scheduler to run it periodically:
2022-05-11 10:28:35 +02:00
/system/scheduler/add interval=2m name=sms-forward on-event="/system/script/run sms-forward;" start-time=startup;
2020-03-27 21:50:27 +01:00
Configuration
-------------
2023-01-09 15:35:57 +01:00
You have to enable receiving of SMS:
/tool/sms/set receive-enabled=yes;
2022-11-03 23:43:08 +01:00
The configuration goes to `global-config-overlay` , this is the only parameter:
* `SmsForwardHooks` : an array with pre-defined hooks, where each hook consists
of `match` (which is matched against the received message), `allowed-number`
(which is matched against the sending phone number or name) and `command` .
2023-10-11 10:03:48 +02:00
For `match` and `allowed-number` regular expressions are supported. Actual
phone number (`$Phone` ) and message (`$Message` ) are available for the hook.
2022-11-03 23:43:08 +01:00
2023-06-07 14:13:54 +02:00
> ℹ ️ **Info**: Copy relevant configuration from
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to
> your local `global-config-overlay` and modify it to your specific needs.
2022-09-23 15:07:30 +02:00
Notification settings are required for
[e-mail ](mod/notification-email.md ),
2025-03-04 17:21:00 +01:00
[gotify ](mod/notification-gotify.md ),
2023-10-11 07:40:55 +02:00
[matrix ](mod/notification-matrix.md ),
[ntfy ](mod/notification-ntfy.md ) and/or
2022-09-23 15:07:30 +02:00
[telegram ](mod/notification-telegram.md ).
2020-03-27 21:50:27 +01:00
2022-11-03 23:43:08 +01:00
Tips & Tricks
-------------
2023-01-09 16:22:18 +01:00
### Take care of harmful commands!
It is easy to fake the sending phone number! So make sure you do not rely on
that number for potentially harmful commands. Add a shared secret to match
into the text instead, for example: `reboot-53cr3t-5tr1n9` instead of just
`reboot` .
2022-11-03 23:43:08 +01:00
### Order new volume
Most broadband providers include a volume limit for their data plans. The
hook functionality can be used to order new volume automatically.
Let's assume an imaginary provider **ABC** sends a message when the available
volume is about to deplete. The message is sent from `ABC` and the text
contains the string `80%` . New volume can be ordered by sending a SMS back to
the phone number `1234` with the text `data-plan` .
:global SmsForwardHooks {
{ match="80%";
allowed-number="ABC";
command="/tool/sms/send lte1 phone-number=1234 message=\"data-plan\";" };
};
Adjust the values to your own needs.
2020-03-27 21:50:27 +01:00
See also
--------
* [Act on received SMS ](sms-action.md )
---
2023-01-10 14:45:27 +01:00
[⬅️ Go back to main README ](../README.md )
[⬆️ Go back to top ](#top )