Automatic SMS Replies

Using the built-in C# or Visual Basic .Net scripting in Diafaan SMS Server you can create automatic replies to SMS messages ranging from simple to very complex. To create an automated SMS reply you first have to add a Scripting Connector in Diafaan SMS Server. In the examples below C# scripts are used but it is also possible to use Visual Basic .Net scripts.

Simple SMS reply

Scripting ConnectorScripting Connector

When an SMS message is received by a GSM modem, the messages are sent to the Scripting Connector. A callback function OnMessageReceived is called in the script with all relevant information about the SMS message as parameters.

The most basic SMS reply action is to send back a fixed text to the sender of the message. This is done with the PostSendMessage function. This function just sends an SMS message to one GSM phone. In this case the same GSM phone number where the message originated.

private void OnMessageReceived(string fromAddress, 
                               string toAddress,
                               string message, 
                               string messageType,
                               string messageId, 
                               string smsc, 
                               string pdu, 
                               string gateway,
                               DateTime sendTime, 
                               DateTime receiveTime)
  PostSendMessage(fromAddress, "", "Thank you for your message",
                  "", "", "", "", 0);

Complex SMS replies

The SMS reply script can be as complicated as is necessary. A simple addition might be the date and time when the message was received, but also replies based on database queries or http requests from a PHP or ASP.NET script are possible.