Sms auto-reply on rutx50

On the rutx50 I’d like to parse a generic incoming sms message for specific keyword(s) and then either send an auto-reply back or to a specific number (yet to be decided) depending on the message being received.

I couldn’t find anything obvious on how to do this but I assume that things like this have already been discussed here…?

Seems like a custom script in the sms-utilities is the way to go.

However there seems to be two issues that I can’t figure out a workaround for. First one is that the custom script adds a status line to my reply message. This is unwanted. Second one is that I’d like to see who the sender is in my script.

Any way around this?

Ok, I solved one of the two issues. After some debugging I found an environment variable called $SMS_FROM so this solved who I got the sms from.

@Marijus, but I still need to get rid of the automatic status message that is being added to the output.

It would be nice to have the following variables at hand in the script: $SMS_TEXT, $SMS_TIME, $SMS_DATE, $SMS_INDEX.

In a future update it would be nice to being able to point directly to a script instead of having to call a script from a script.

It would also be nice being able to duplicate an existing rules and similar, not restricted to sms only.

What would otherwise be the proper way of intercepting sms-messages before/after the sms-utilities?

While waiting for a proper answer I found the sms binary and patched it so that it no longer adds the status message.

I had to do a similar thing with the sms rules since it normally doesn’t accept a sms text trigger that includes a comma, like in “Hello,”.

Hello,

Am I correct in understanding that you’ve resolved your queries? If so, do you have any additional questions or need help with anything else?

Best Regards,

@Marija, I would not considered this resolved. It is more a proof of concept.

  1. I had to edit your /usr/sbin/sms_utils binary (no source code available) to get rid of an unwanted status message that interfered with my output. This will break the moment you release an update. This status message must be made optional for the user.

  2. The sms rules does not accept the comma as a valid letter, but by manually editing the /etc/config/sms_utils configuration file I was able to add that comma. Due to this it is not possible to use the gui to edit that entry and must be handled manually. Why is the comma excluded? It will not accept parentheses either.

  3. What is the proper way of intercepting sms messages before sms_utils? The current rules are lacking when it comes to parsing more generic messages. It should be possible to use regexp or similar mechanism to parse an incoming message. A generic option to run a script when ANY message is received from a certain number. As it is right now I’m unable to have different rules for the same type of message but from different numbers. If I get a message that doesn’t trigger a rule I might want to have a default rule for this condition for logging spammers or erroneous messages, which currently isn’t possible. Another problem is that a 3’rd party device may send a message that starts with a generic identifier (but might contain a timestamp), thus making it not possible to trigger on the following message.

I mentioned above some extra environment variables that would be very good to have when parsing a sms.

I would consider #1 and #2 to be bugs while #3 is a feature request that would be beneficial for many.

Oh, I forgot:

When scripting I find no way of aborting a message reply. It must be possible to not send a reply message when scripting.

Hello,

Thank you for the suggestions. We strive to ensure every function is as comfortable as possible for all our clients. While these functions were not previously needed, we will review your suggestions for potential implementation.

Regarding the comma, it may be excluded from the SMS rules configuration to simplify message parsing, ensure compatibility with existing systems, and minimize the risk of errors in SMS processing.

You can have different rules for the same type of messages but from different numbers. For example, you can add these lines to define specific phone numbers and corresponding actions/rules:

RULES=(
    "phonenumber1|action1"
    "phonenumber2|action2"
)

To avoid sending a reply message in your script, you can implement conditional logic to determine whether a reply should be sent based on certain conditions. For instance:

# Check if the SMS contains any of the specified keywords
if echo "$SMS" | grep -qE "$KEYWORD"; then
    # Process the message and determine if a reply should be sent
    if should_send_reply "$SMS"; then
        # Send an auto-reply back to the sender
        send_reply "$SMS"
    else
        # Log that no reply is sent
        echo "No reply sent for message: $SMS"
    fi
fi

Best Regards,

@Marija, tnx I will check the rule. But will this not break the gui making that entry not editable?

With script I meant the custom scripts in the sms-utilities. Even with my hack sms-utils will send an empty message. sms-utils custom scripts will take anything sent to stdout (and stderr?) and send that to the recipient which is ok but since any script will have the status message added it will always send a reply, no matter what. This means that there is no way for a custom script to not send anything.

This topic was automatically closed after 15 days. New replies are no longer allowed.