MO Return API and Classifications
MO Return API
The return processing API allows you to program specific actions according to the lead's classification.
Remember to enable the callback for receiving DLR and MO. More information »
To create a script, go to the SMS Configuration menu > Advanced > MO Script.
In the "MO Script - Code (C#)" field, click the DEFAULT button to load the sample script:
Boolean OnExecute(izLeads.Business.CSScriptHelperSMS helper,
izLeads.Business.Data.Public.Sms_resposta resposta,
izLeads.Business.Data.Public.Sms_resposta_tratamento tratamento)
{
Boolean retorno = false;
try
{
helper.Debug("Response Received");
helper.Debug(String.Format("id={0}, From={1}, To={2}, RemoteId={3}, " +
"receivedDate={4:dd/MM/yyyy hh:mm:ss}, companyId={5}, classification={6} -> {7}",
resposta.idResposta,
resposta.From,
resposta.To,
resposta.RemoteID,
resposta.DataRecepcao,
resposta.IdEmpresa,
resposta.Classificacao,
resposta.Mensagem
));
// your code
String ApiKey = "<<insert your api key>>";
helper.SMSService_APIURL = "https://apidb.witi.me/sms/send.aspx?chave=" + ApiKey;
helper.Debug(String.Format("Action: {0}", tratamento.Acao));
// Example of generic SMS sending
if(tratamento.Acao == "LEAD")
{
int routeId = 456;
string body = String.Format("from={0},to={1},classification={2},message={3}",
resposta.From, resposta.To, resposta.Classificacao, resposta.Mensagem);
// Uncomment to send a reply
helper.EnviaSMS("Good evening", resposta.From, routeId, null);
}
tratamento.Tratado = true;
// to reply to SMS test, via the same route,
// fill this variable
// tratamento.ResponderTexto = "Reply 123";
retorno = true;
}
catch(Exception ex)
{
helper.Debug(ex);
}
finally
{
helper.Debug("End OnEvaluate");
}
return retorno;
}
The code above contains explanations and some examples, but you can use standard C# functions as well as the special helper functions (see the 'helper' section of the service bot by clicking here).
Classification
Configure the lead's classification according to the received response (MO). You can compare by exact words or by regular expression.
To start configuration, go to the SMS Configuration menu > Advanced > Classification and click the DEFAULT button. The configuration is done through a JSON file:
[
{
"TextoPesquisa": "NO",
"TipoCorrespondencia": 0, // 0 = exact, 1 = regular expression
"prioridade": 0,
"Enabled": true,
"Nome": "exact_1",
"Acao": "ignore",
"Tag": "ignore"
},
{
"TextoPesquisa": "YES",
"TipoCorrespondencia": 0,
"prioridade": 0,
"Enabled": true,
"Nome": "exact_2",
"Acao": "LEAD",
"Tag": "LEAD"
},
{
"TextoPesquisa": "(EXIT|CANCEL|STOP|REMOVE|EXCLUDE|EXCLUSION|REMOVE ME|TAKE OUT|UNSUBSCRIBE|SCAM|DON'T WANT ANYMORE|CAN'T TAKE IT|WITHDRAW|EXIT)",
"TipoCorrespondencia": 1,
"prioridade": 100,
"Enabled": true,
"Nome": "regularExpression_1",
"Acao": "blackList",
"Tag": "blackList"
},
...
]