How can we help?

A case study in automated message processing


A company called ‘SouthWind’ is running Auron SMS Server.

It has two cases running simultaneously. The first case is a workflow system, where 3 dedicated employees (+4400000001, +4400000002 and +4400000003) can send their workflow results to the central office through SMS. The second case is to serve product database requests via SMS, so employees and customers can query a product database from remote, to retrieve price information and stock quantities.

An incoming message is analyzed on its contents:
If it is received from one of the ‘+44000000x’ numbers, it is apparently a workflow request.
If not, the body of the message is checked for the existence of the ‘PRODUCT’ keyword. If it does contain this keyword, it is apparently a product database request.
If not, the message is neither a workflow message nor a product database query, so the system replies with the following SMS message:
“Request cannot be handled by the system”.

To implement this system, we will create three triggers: one trigger to process the workflow requests, one trigger to process the product requests, and one trigger to process all other SMS messages.

You can now create the triggers:

# Type Status Condition Script
1 SMS Received FromAddress=’+4400000001′ OR FromAddress=’+4400000002′ OR FromAddress=’+4400000003 WorkFlow.vbs
2 SMS Received Body LIKE ‘PRODUCT%’ ProductInfo.vbs
3 SMS Received UnknownMessage.vbs

These triggers can be created with the ‘Empty VBScript’ trigger template.

It is important that Trigger 3 has a lower priority than the other triggers. You can change the processing order in the Triggers Processing order dialog:

  • Launch the SMS Server Manager application from the Start menu;
  • Select the Triggers folder;
  • Click on Change Processing Order.

Script 1: [WorkFlow.vbs]

The first script is executed if the first condition is matched. The script performs the following actions:

  • It sets the trigger status of the incoming message to MESSAGETRGSTATUS_PROCESSED, so it won’t match the condition of the second and third trigger;
  • It updates the custom workflow database (implementation of this update is beyond the scope of this sample);
  • It generates a new outgoing pending SMS message, addressed to the sender of the incoming message, to thank the sender for the SMS message.

The script:

  CONST STR_DEBUGFILE     = "Log\workflow.txt"
  CONST B_ENABLE_DEBUG    = True

  ' Creation of global objects
  Set g_objConstants  = CreateObject( "AxMmServer.Constants" )
  Set g_objFso        = CreateObject( "Scripting.FileSystemObject" )
  
  Function ProcessMessageEx( objMessageIn, objMessageDB, dctContext )
  
    ' Set incoming SMS message status to PROCESSED, so it won't be processed 
    ' by the next trigger
    objMessageIn.StatusID = g_objConstants.MESSAGETRGSTATUS_PROCESSED
   
    ' Update the workflow - custom function
    UpdateWorkflow( objMessageIn.FromAddress, objMessageIn.Body ) 
   
    ' Create a new reply message, and save it
    Set objMessageOut = objMessageDB.Create( "SMS" ) 
    objMessageOut.StatusID    = g_objConstants.MESSAGESTATUS_SCHEDULED
    objMessageOut.ToAddress   = objMessageIn.FromAddress
    objMessageOut.ChannelID   = ""  ' Any available SMS channel
    objMessageOut.Body        = "Your request has been processed successfully."
    objMessageDB.Save objMessageOut
  
  End Function
    
  Function UpdateWorkflow( strSender, strBody )
    ' Custom function to update the sender's workflow data
  End Function

Script 2: [ProductInfo.vbs]

This script is very similar to the first script. Instead of updating a worksheet, the script fetches Product information based on the request, and replies it to the original sender.

  CONST STR_DEBUGFILE     = "Log\ProductInfo.txt"
  CONST B_ENABLE_DEBUG    = True

  ' Creation of global objects
  Set g_objConstants  = CreateObject( "AxMmServer.Constants" )
  Set g_objFso        = CreateObject( "Scripting.FileSystemObject" )
  
  Function ProcessMessageEx( objMessageIn, objMessageDB, dctContext )
       
    ' Set incoming SMS message status to PROCESSED, so it won't be processed 
    ' by the next trigger
    objMessageIn.StatusID = g_objConstants.MESSAGETRGSTATUS_PROCESSED
    
    ' Retrieve product info from a custom database - custom function
    strProductInfo = GetProductInfo( objMessageIn.Body ) 
    
    ' Create a new reply message, and save it
    Set objMessageOut = objMessageDB.Create( "SMS" ) 
    objMessageOut.StatusID    = g_objConstants.MESSAGESTATUS_SCHEDULED
    objMessageOut.ToAddress   = objMessageIn.FromAddress
    objMessageOut.ChannelID   = ""  ' Any available SMS channel
    objMessageOut.Body        = strProductInfo
    g_objMessageDB.Save objMessageOut
  
  End Function
    
  Function GetProductInfo( strBody )
    ' Custom function to update the sender's workflow data
    ...
    GetProductInfo = "In Stock: XXX; Price: YYY"
  End Function

Script 3: [UnknownMessage.vbs]

This script is very similar to the first script. It only replies to the original sender that the request is invalid.

  CONST STR_DEBUGFILE     = "Log\workflow.txt"
  CONST B_ENABLE_DEBUG    = True

  ' Creation of global objects
  Set g_objConstants  = CreateObject( "AxMmServer.Constants" )
  Set g_objFso        = CreateObject( "Scripting.FileSystemObject" )
  
  Function ProcessMessageEx( objMessageIn, objMessageDB, dctContext )
  
    ' Set incoming SMS message status to PROCESSED, so it won't be processed
    ' by the next trigger
    objMessageIn.StatusID = g_objConstants.MESSAGETRGSTATUS_PROCESSED
   
    ' Create a new reply message, and save it
    ' Create a new reply message, and save it
    Set objMessageOut = objMessageDB.Create( "SMS" ) 
    objMessageOut.StatusID    = g_objConstants.MESSAGESTATUS_SCHEDULED
    objMessageOut.ToAddress   = objMessageIn.FromAddress
    objMessageOut.ChannelID   = ""  ' Any available SMS channel
    objMessageOut.Body        = "Invalid request."
    g_objMessageDB.Save objMessageOut
  
  End Function