Twilio Direct Calling with notifyAction.addSay()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 11:01 AM
Hello everyone,
I have integrated a Twilio trial account with my PDI. I am able to send SMS messages just fine using a business rule with simple script (see below). I am now trying to initiate a call. This works okay but hangs up after about 3 seconds. My goal is to initiate a call and have text to speech give me a verbal message, THEN hang up.
(see API https://developer.servicenow.com/dev.do#!/reference/api/utah/server_legacy/c_NotifyAPI#r_N-call_S_S_...).
Working code for sending SMS:
//Get Notify From Number
var notifyNum = new GlideRecord('notify_number');
notifyNum.get('notify_group.name', 'Notify On Task Group');
var message = 'Test SMS: Incident Number ' + current.number;
SNC.Notify.sendSMS(notifyNum.number, current.assigned_to.mobile_phone, message, current);
Working Code for Sending Call:
//Get Notify From Number
var notifyNum = new GlideRecord('notify_number');
notifyNum.get('notify_group.name', 'Notify On Task Group');
new SNC.Notify().call(notifyNum.number, current.assigned_to.mobile_phone, SNC.Notify.conferenceCall());
*I can do this with or without the conference call.
Non-working Code to Initiate Call and invoke NotifyAction to have the text to speech using addSay() method
//Get Notify From Number
var notifyNum = new GlideRecord('notify_number');
notifyNum.get('notify_group.name', 'Notify On Task Group');
var callRecord = new SNC.Notify().call(notifyNum.number, current.assigned_to.mobile_phone);
var notifyAction = new SNC.NotifyAction();
var speech = notifyAction.addSay();
speech.setText('Welcome. I can speak english');
speech.setLanguage('en-US');
new SNC.Notify().modifyCall(callRecord, notifyAction);
*Note this is without the conference call parameter. This call will initiate but after I pick up the phone and press a key to run the code I get a verbal error message of "Application was invoked incorrectly. No conference was provided something something". When I add the conference call back in, I don't get the error message anymore. However I know have to press 1 to join the conference call and then I just hear conference call music. No text to speech message.
I am not finding very much information other than from the API which tells me to use the modifyCall method in order to use the NotifyAction. I feel like I am using this wrong in some way.
I welcome your input.
Thanks,
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 05:38 AM
Could you let me know if you found a solution? I have the same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 06:57 AM
Hi David,
My solution on this was to use call the Twilio API directly for voice calls. There is example code you can put in your business rule found here: https://github.com/Cfee2000/ServiceNowTwilioStudioIntegration/blob/main/snow_businessRule_scripts/as...
From there you need to build a flow in Twilio Studio that receives that API call. You can pass the phone numbers and say message to that flow. Here is an example: