On-Call Notify with Twilio

ranjithkariminl
Tera Guru

Hi All,

I am trying to configure on-call scheduling notify with Twilio to make REST API call for SMS and Phone call. We are using OOB workflow "On-Call: Assign and Notify". This workflow has block called Send SMS notification. How can we pass Incident information to assigned group on call person through Twilio phone number? Any sample scripts help to modify below block.

find_real_file.png

Thanks,

Ranjith

4 REPLIES 4

Sanjeev Kumar1
Kilo Sage

Vignesh11
Tera Expert

Hi Ranjith,



My suggestion would be for you to go with Notify API's, as we have implemented ON-call scheduling using OOB notify API and modifying the workflows as per our requirement.


For on call the REST API would be more complex and tricky for all scenarios.


If you are facing any hiccups in OOB functionalities raise HI.


chedley
Tera Contributor

I am looking for something similar on how to send to all the members of the specified group - using that workflow action will only ever send to one person of the group I choose, no matter the group. Sending to an array seems to not work in my Helsinki instance.


I had a similar use case. My use case didn't involve a workflow, but you could use similar logic to accomplish sending to a group.



Inside of Incident Alerts I created a UI Action. On-click the UI action retrieves a system property that is an array of phone numbers. I use this property for people that want to to be notified when an outage occurs.



It then uses an ajax call to a script include passing the array to a function that loops through each phone number sending a text to each phone number.   You could easily do this in a workflow as well.   Here is an example of looping through an array to send a text message.   If you need more detail on how to do this for an assignment group I an assist with that as well.



sendSmsText: function() {


var sourceID = this.getParameter('sysparm_id') + '';



// define our AJAX XML response root node


var payload = this.newItem('groupText');


payload.setAttribute('success', 'false');



// set worknotes variable


var beginNotes = gs.getMessage("Attempted to send Major Incident Text Notification to the following recipients: \r\n");


var recipientNotes = '';



// get recipients


var recipientGroup = this.getParameter('sysparm_group');


var recipients = this._getGroupMembers(recipientGroup);


//recipients = (JSUtil.notNil(recipients)) ? recipients.split(',') : [];



//get message loop through recipients and send text


var message = this.getParameter('sysparm_message');


var success = 0;


for (var i = 0; i < recipients.length; i++) {


var recipient = recipients[i];



// send text to each recipient


//var id = recipient.id;


var user = this._getUserByID(recipient.id);



if (this._text(user.name,user.u_oncall_number,message))


success++;



// success?


if (success > 0) {


// update the payload to success


payload.setAttribute('success' , 'true');


recipientNotes = recipientNotes   + user.name + '-' + user.u_oncall_number + '\r\n';


} else {


gs.addErrorMessage(gs.getMessage('A recipient had an invalid on-call phone number'));


}


},


_text: function(name,to,message){



var from = gs.getProperty('com.snc.iam.notify_number', '');



// got a from number?


if (JSUtil.nil(from)) {


gs.addErrorMessage(gs.getMessage('Configure com.snc.iam.notify_number property to contain the Notify number to use'));


return false;


}



// got a number?


if (JSUtil.notNil(to)) {


// send SMS text to user


this.notify.sendSMS(from, to, message);


return true;


} else {


gs.addErrorMessage(gs.getMessage('recipient {0} could not be added to group text',[name]));


return false;


}



},