API de Retorno MO y Clasificaciones
API de Retorno MO
La API de procesamiento de retorno te permite programar acciones específicas según la clasificación del lead.
:::danger Importante Recuerda habilitar el callback para recibir DLR y MO. Más información » :::
Para crear un script, ve al menú Configuración SMS > Avanzado > Script MO.
En el campo "Script MO - Código (C#)", haz clic en el botón DEFAULT para cargar el script de ejemplo:
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;
}
:::info Helper
El código anterior contiene explicaciones y algunos ejemplos, pero puedes usar funciones estándar de C# así como las funciones especiales del helper (consulta la sección 'helper' del bot de servicio haciendo clic aquí).
:::
Clasificación
Configura la clasificación del lead según la respuesta recibida (MO). Puedes comparar por palabras exactas o por expresión regular.
Para comenzar la configuración, ve al menú Configuración SMS > Avanzado > Clasificación y haz clic en el botón DEFAULT. La configuración se realiza a través de un archivo JSON:
[
{
"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"
},
...
]