Automatic SMS replies by script

The guide on this page is going to give you a brief introduction to how easy you can create an autoreply service that uses a script to answer by a defined action to the received messages. (Figure 1) This service is capable of just reply with a predefined message, but you can write a script to forward the incoming messages to a specific phone number or do actions in case the sender phone number or the message itself matches with your predefined details. So, let's start it right now.

autoresponding sms script
Figure 1 - Autoresponding SMS script

How to write an SMS reply script (Easy commands)

To write an SMS reply script:

  1. Launch Ozeki SMS Gateway
  2. Select the Apps toolbar icon
  3. Install Autoreply app
  4. Write a test SMS script
  5. Specify the Sender address
  6. Enable the Connection
  7. Select Connect toolbar icon
  8. Add new SMPP client connection
  9. Check the new autoreply routing rule

Video 1 - How to write an SMS reply script (Video tutorial)

Step 1 - Create an Autoreply connection

The first thing that you need to do in this guide, is to create the autoreply service connection in the SMS Gateway. So, for that, first, click on the Apps icon on the toolbar in the main menu. Here you can see all the available connections, that you can create in the SMS Gateway. Now, but need to scroll down to the 'Incoming SMS message processing and autoresponding services' section, and here, like in Figure 2, click on the Install button of the Autoreply connection.

create an autoreply connection
Figure 2 - Create an Autoreply connection

Step 2 - Configure the Autoreply connection

In the configuration menu of the Autoreply connection, you need to specify a name for the connection in the first step. Then, you select the way, that the connection uses the script to handle the incoming messages. As you can see it in Figure 3, you can set the path for a script file, that the connection can use, or you can just type the script in the textbox below.

configure the autoreply connection
Figure 3 - Configure the Autoreply connection

Step 3 - Select an example script

The easiest way to create this autoreply service is to just select one from the available four example scripts from the textbox. Right now, they can't be executed since all lines commented out by an '#' sign. The first example script sends a 'Thank you' message back to the sender.

n.*
SENDER Thank you for your message.
STOP

The second example script is capable of forwarding all the incoming messages to the defined phone number. The second line of the script shows how you can do that by first, defining the phone number, and then, MSG variable stores the incoming message which is in this case will be sent to that phone number.

n.*
+3620123223 MSG
STOP

The next example script activates only when the message comes from a specified phone number. This phone number can be defined in the first line of the script. Then, the script forwards the message to the phone number that is defined in the second line. The MSG variable stores the message.

n^+362000001
+3620123223 MSG
STOP

The last example shows how you can do an action in case the message starts with a specific word. This example forwards the message to two other phone numbers defined in the second and third row. But it happens only in case when the message starts with the word 'important'. The word can be defined as the first row of the script demonstrates it.

m^important.*
+3620123223 SENDER: MSG
+3670322321 MSG
STOP

To follow this guide, just select the script that will forward the message to the defined phone number. Figure 4 demonstrates, how you need to write the script into the textbox to be able to operate with that script in case of an incoming message.

write a script for the autoreply service
Figure 4 - Write a script for the Autoreply service

Step 4 - Advanced configuration of Autoreply connection

The Autoreply connection can be further configured by setting a default sender address. This address will show up at the recipient side who receives the reply message. As you can see it in Figure 5, you can type here a phone number or an e-mail address which helps to identify the autoreply easy connection. If you finished the configuration, just click on OK.

advanced configuration of the autoreply connection
Figure 5 - Advanced configuration of the Autoreply connection

Step 5 - Enable the Autoreply connection

After you created the Autoreply connection, the next window is the main menu of the autoreply service. Here, you can modify the details of the connection anytime you want. To activate the service, you need to enable the connection here. For that, just click on the toggle as Figure 6 shows. The toggle is green now that indicates that the autoreply service is now active.

enabling the autoreply connection
Figure 6 - Enabling the Autoreply connection

Step 6 - Connect to the mobile network

By this point, you created and enabled your autoreply service, but to receive messages, you also need a connection that can connect to the mobile network and forward messages to your Ozeki system. To do that, click on Connect on the toolbar, and select the SMPP client as you can see it in Figure 7.

create an smpp client connection
Figure 7 - Create an SMPP client connection

In the configuration menu, you have to provide some details about the server. This is the server, that this SMPP client is going to use to handle SMS messages. So here, you need to type the host, port, and user account details. Then, you need to specify a telephone number for this connection (Figure 8). With this number, the connection can be identified, and able to send or receive messages. Lastly, you just need to click on OK to create the SMPP client connection.

configure an smpp client
Figure 8 - Configure an SMPP client connection

Step 7 - Wait for the messages

After setting up and enabling the autoreply service, now it is ready for the incoming messages. You can check that easily in the main menu of the SMS Gateway. Figure 9 shows that the creation of the autoreply service established a routing rule as well. This rule routes all the incoming messages to the autoreply connection and it will just do its job and forward the messages to the dedicated phone number.

route incoming messages to the autoreply connection
Figure 9 - Route incoming messages to the Autoreply connection

Figure 10 demonstrates how simple an autoreply service works. All you need to do here is to wait for a message forwarded to the telephone number, that you gave for the SMPP client connection. As soon as the client received the message, it forwards it straight to the autoreply service.

incoming messages routed to the autoreply service
Figure 10 - Incoming messages routed to the autoreply service

When the Autoreply service receives the message, the script, that you wrote for the service will be executed. In this case, it will forward the incoming message to the specified phone number as Figure 11 shows that.

the autoreply service forwards the message
Figure 11 - The autoreply service forwards the message

FAQs

Can I use keywords to match replies to submitted messages?

Yes.

Keeping track of conversations in SMS can be frustrating because unlike chat apps, SMS messages don't have a built-in way to link them together. This means you can't necessarily tell if an incoming message is a reply to a specific SMS you sent earlier.

One common way to work around this limitation is to use keywords. You can include a unique keyword in the original message you send and ask the recipient to include that same keyword in their reply. This creates a connection between the messages, allowing you to associate the reply with the original message. However, this method relies on the recipient remembering the keyword, which can be unreliable. Forgetting to include the keyword can lead to confusion about which message the reply is actually for.

If you need a more reliable way to track SMS conversations, you might need to consider alternative solutions. For users with IP SMS connections and service providers that support long codes (special sender numbers with more digits), there's a potential solution. You can encode extra digits within the sender number to identify the original message. However, this trick depends on specific service provider capabilities and isn't a universally available option. In the end, while keywords can be a helpful strategy for SMS, they have limitations. For scenarios where message history is crucial, using a platform designed for conversations might be a better choice.

Can I use long codes to match replies to submitted messages?

Yes, if you have an IP SMS connection, and a network that allows this.

Long codes, phone numbers with a special extension (like +36201234678888, where 8888 is the extension), can be used with IP SMS connections in specific networks. Here's the idea:

  • The Long Code Advantage: If your network supports long codes, the recipient (with phone number +3620123467 in our example) would receive any message sent to a number starting with +3620123467. This means messages sent to +36201234678888 or +3620123467999999 would both be delivered to the same recipient.
  • Message ID in the Tail: Since you control the long code, you can encode a message identifier in the final digits of the sender number (like +3620123467****). This way, when a reply comes back to the long code, you can identify which original message it belongs to by looking at the message identifier embedded in the sender number.

More information