Example for a SMS-Box-Script
Back to Create a SMS-Box-Script...
A simple case study to create a SMS script is explained in more detail.
We assume that you want to forward all SMS to the customer's service, that contain the text "Seriennnummer # # # #". So the script would look as follows including error handling:
try
{
var seriennummer_array = helper.extractByRegExp(sms.smsText,"Seriennummer: ([0-9]+)", false);
if (seriennummer_array != null && seriennummer_array.length > 0)
{
var seriennummer = seriennummer_array[0];
helper.routeToGroupByName("Kundendienst");
}
}
catch ( e )
{
if(e.rhinoException != null)
{
println("Rhino Exception: " + e)
e.rhinoException.printStackTrace();
}
else if(e.javaException != null)
{
println("Java Exception: " + e)
e.javaException.printStackTrace();
}
else
{
println("Exception: " + e);
}
}
{
var seriennummer_array = helper.extractByRegExp(sms.smsText,"Seriennummer: ([0-9]+)", false);
if (seriennummer_array != null && seriennummer_array.length > 0)
{
var seriennummer = seriennummer_array[0];
helper.routeToGroupByName("Kundendienst");
}
}
catch ( e )
{
if(e.rhinoException != null)
{
println("Rhino Exception: " + e)
e.rhinoException.printStackTrace();
}
else if(e.javaException != null)
{
println("Java Exception: " + e)
e.javaException.printStackTrace();
}
else
{
println("Exception: " + e);
}
}