Script on Cati call
More actions
Script on Cati call
Add the ability to call a script after each time a number has been dialed, also set via the cati settings. This will allow us better control of when to do various stuff, and also allow custom logic for some cases... e.g. in the rerecruitment we can say that when it reach the maxdial status, then we opt people out of panel. Or we can send SMS to people with answering machines that we will call them back. It should be noticed that the calling of this script is on the critical path, and must therefore be severely restricted in the amount of work done, ie in the case of sending SMS, the only thing the script should do is add respondent to a group and another script scheduled to run e,g. every 30 min takes care of the actual sending of SMS.
The script gets the following parameters:
1. The current cati contact in same format as returned from CATI_getCATIContacts
2. Times called
The current user context is set to the user of the qas, and the qas context is the dialed qas.
Setup
Define "Script to execute after call" at CATI setting on Fieldwork management:
Script on Workflow:
//Example script to add/remove the user to/from a group
array a = Workflow_getParameters();
array currentCatiContact = a[0];//same format as returned from CATI_getCATIContacts
number timesCalled = a[1];
//QAS qas = QAS_getCurrentQAS();//The qas context is the dialed qas
User user = User_getQasUser();//The current user context is set to the user of the qas
number maxCallLimit = 5;//your limit
if(timesCalled >= maxCallLimit){
Group_addUser(user.ResourceId, groupAdd) ;//yourGroup
Group_removeUser(user.ResourceId, groupRemove) ;//yourGroup
}
Please note that if the code has an error, it will not be thrown; Cati will continue to call normally. If you want to catch errors, you should use a try-catch block and send the error back to yourself.
object e;
try{
//do something
}catch(e){
sendEmail("yourEmail","Alias","Subject",e.Message,"fromEmail");
}