Hello all,
First of all, I don't know if I am in the correct "folder" on this site, and if I'm not, sorry.
I made this script with a little help from ChatGPT (I know, it's cheating ) for my needs. In my country, like many others, the most usable internet is via LTE/5G. Most providers don't offer true unlimited (FLAT) internet; instead, once you use up the data included in your payment plan, you need to send a message to a certain number to continue surfing at the maximum available speed. If you don't send that message, your speed is limited to approximately 4Mbps.
This is my situation as well, so I created this auto-reply SMS script to avoid manually sending the SMS each time I use up 20GB of traffic.
This is the script :
______________________________________________________________________________________________________________________________________________________________
/system script add name=auto-reply-sms source={
:local senderPhone "YOUR_INPUT"
:local message "YOUR_INPUT"
:local responseNumber "YOUR_INPUT"
:local responseMessage "YOUR_INPUT"
:local notifyNumber "YOUR INPUT"
:local notifyMessage "YOUR_INPUT"
# Check for messages from the specific sender
:local messages [/tool sms inbox find]
:foreach i in=$messages do={
:local messageText [/tool sms inbox get $i message]
:local senderNumber [/tool sms inbox get $i phone]
:log info ("Processing message from " . $senderNumber . ": " . $messageText)
# Check if the message is from the specific sender and contains the keyword
:if (($senderNumber = $senderPhone) && ([:find $messageText $message] != -1)) do={
:log info ("Keyword found in message from " . $senderNumber)
# Check if we've already replied to this keyword
:local alreadyReplied [/tool sms inbox find where phone=$responseNumber and message=$responseMessage]
:if ([:len $alreadyReplied] = 0) do={
:log info ("Reply not sent yet, sending reply to " . $responseNumber)
/tool sms send phone=$responseNumber message=$responseMessage
:log info ("Sending notification to " . $notifyNumber)
/tool sms send phone=$notifyNumber message=$notifyMessage
} else={
:log info ("Already replied to this keyword")
}
}
}
# Remove all messages from the SMS inbox to prevent it from getting full
/tool sms inbox remove [find]
}
______________________________________________________________________________________________________________________________________________________________
I just added lines to divide the script from the text. The script is fairly simple, and it works as intended (the lazy way ).
Anyway, you can see in the script YOUR_INPUT, which indicates where you should check the inbox and change according to your specific details. The lines :local notifyNumber and :local notifyMessage are not mandatory. I just added them to notify me on my phone when the router sends a reply message so I can monitor how often it sends.
All you need to do is add a scheduler with an appropriate interval for how often you want to run the script. You can add it via the terminal as well:
______________________________________________________________________________________________________________________________________________________________
/system scheduler add name=auto-reply-sms-scheduler interval=1h on-event=auto-reply-sms
______________________________________________________________________________________________________________________________________________________________
I hope it will help someone.
Cheers.