NotifyAction - Global

The NotifyAction API allows you to define actions to send to a telephony provider.

You add actions to a NotifyAction object by calling the respective add function for each type of action.

Each add function returns an Action object, such as a SayAction object for the addSay() function. Refer to each method example for information about returned objects.

NotifyAction - addConference()

Add a call to a Notify conference call.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
ConferenceAction The action added to the NotifyAction object. Use the ConferenceAction object to define the conference call name, and the behavior of the conference call when a participant joins or leaves.

NotifyAction - addDial()

Make an outbound call.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
DialAction The action added to the NotifyAction object. Use the DialAction object to define.

var action = new SNC.NotifyAction(); 
var dial = action.addDial();
dial.setRecord(activity.vars.record);
dial.setClientRecord(activity.vars.user, "sys_user");

NotifyAction - addGather()

Present an interactive phone menu to the user.

Table 5. Parameters
Name Type Description
None
Table 6. Returns
Type Description
GatherAction The action added to the NotifyAction object. Use the GatherAction object to define the menu settings and options to present to the user.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// present the user with a menu
var gather = notifyAction.addGather();
gather.setNumberOfDigits(1);    // the user can type 1 digit
gather.setFinishKey('#');       // # or *, usefull for > 1 digits
gather.setTimeout(10);          // time to enter answer, in seconds

// add first menu item
var usSay = gather.addSay();
usSay.setText('Press 1 for english');
usSay.setLanguage('en-US');

// add second menu item
var nlSay = gather.addSay();
nlSay.setText('Kies 2 voor Nederlands');
nlSay.setLanguage('nl-NL');

// add third menu item
var frSay = gather.addSay();
frSay.setText('Choisissez 3 pour le fran├žais.');
frSay.setLanguage('fr-FR');

// and finish off with an applause
var play = gather.addPlay();
play.setURL('http://www.wavsource.com/snds_2015-04-12_5971820382841326/sfx/applause_y.wav');

NotifyAction - addHangUp()

End an active phone call.

Table 7. Parameters
Name Type Description
None
Table 8. Returns
Type Description
HangUpAction The action added to the NotifyAction object.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// hang up
notifyAction.addHangUp();

NotifyAction - addQueue()

Queue the call, putting it on hold.

Table 9. Parameters
Name Type Description
None
Table 10. Returns
Type Description
QueueAction The action added to the NotifyAction object. Use the QueueAction object to define the queue name, and queueing or dequeueing behavior.
// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// queue the call
var queue = notifyAction.addQueue();
queue.setName('my queue');
// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// dequeue the call
var queue = notifyAction.addQueue();
queue.setDequeue(true);

NotifyAction - addPlay()

Play an audio file on the call.

Table 11. Parameters
Name Type Description
None
Table 12. Returns
Type Description
PlayAction The action added to the NotifyAction object. Use the PlayAction object to define the audio file URL and number of times to loop the audio.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// add a play action
var play = notifyAction.addPlay();
play.setURL('http://www.moviesounds.com/2001/imsorry.wav');
play.setLoop(1);

NotifyAction - addReject()

Reject an incoming call.

Table 13. Parameters
Name Type Description
None
Table 14. Returns
Type Description
RejectAction The action added to the NotifyAction object. Use the RejectAction object to define the reason for rejecting the call.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// reject the call
var rejectAction = notifyAction.addReject();
rejectAction.setReason('busy'); // 'busy' or 'rejected'

NotifyAction - addSay()

Use text-to-speech to read text on the call.

Multiple languages are supported with text-to-speech. Available languages depend on the telephony provider.

Table 15. Parameters
Name Type Description
None
Table 16. Returns
Type Description
SayAction The action added to the NotifyAction object. Use the SayAction object to define the text and language to read.

This example demonstrates reading text in several languages.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// add a say action to say something in US English
var usSay = notifyAction.addSay();
usSay.setText('Welcome. I can speak english');
usSay.setLanguage('en-US');

// add a say action to say something in Dutch
var nlSay = notifyAction.addSay();
nlSay.setText('Ik spreek ook vloeiend nederlands');
nlSay.setLanguage('nl-NL');

// and german
var deSay = notifyAction.addSay();
deSay.setText('Und ich kan auch deutsch sprechen');
deSay.setLanguage('de-DE');

NotifyAction - addSMS()

Send an SMS message.

When using this function with an active call, you do not need to call the setTo function on the returned SMSAction object. The SMS is automatically sent to the caller.

Table 17. Parameters
Name Type Description
None
Table 18. Returns
Type Description
SMSAction The action added to the NotifyAction object. Use the SMSAction object to define the message text and the phone number to send the message to.

// instantiate NotifyAction
var notifyAction = new SNC.NotifyAction();

// define where to send the sms to
var number = new GlideElementPhoneNumber();
number.setPhoneNumber('+31612345678', true);

// add a SMS action
var sms = notifyAction.addSMS();
sms.setMessage('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
sms.setTo(number);

NotifyAction - fromJson(String json)

Deserialize a NotifyAction object from a JSON string.

Table 19. Parameters
Name Type Description
json String A JSON string representation of a NotifyAction object.
Table 20. Returns
Type Description
void

This example demonstrates deserializing a NotifyAction object.

var json = ".... some json obtained from toJson ....";

// instantiate notify action
var notifyAction = new SNC.NotifyAction();

// deserialize and reconstruct the notify action instance
notifyAction.fromJson(json);

This example demonstrates both serializing and deserializing a NotifyAction object.

// instantiate notify action
var notifyAction = new SNC.NotifyAction();

// add a queue
var queue = notifyAction.addQueue();
queue.setName('myQueueName');
queue.setDequeue(false);

// serialize to json
var json = notifyAction.toJson();
gs.log('serialization result: ' + json);

// instantiate a new notify action
var newAction = new SNC.NotifyAction();

// deserialize the json generated above
newAction.fromJson(json);

// serialize the new object and log the result
newJson = newAction.toJson();
gs.log('new serialization result: ' + newJson);
gs.log('the same: ' + (json == newJson));

Output: *** Script: serialization result: {"fClassName":"NotifyAction","fActions":[{"fClassName":"QueueAction","fDequeue":true,"fQueueName":"myQueueName"}]} *** Script: new serialization result: {"fClassName":"NotifyAction","fActions":[{"fClassName":"QueueAction","fDequeue":true,"fQueueName":"myQueueName"}]} *** Script: the same: true

NotifyAction - toJson()

Serialize the NotifyAction object to a JSON string.

Table 21. Parameters
Name Type Description
None
Table 22. Returns
Type Description
String A JSON representation of this NotifyAction object.

This example demonstrates serializing a NotifyAction object.

// instantiate notify action
var notifyAction = new SNC.NotifyAction();

// add one or more notify actions
// ...

// and serialize to json
var json = notifyAction.toJson();

This example demonstrates both serializing and deserializing a NotifyAction object.

// instantiate notify action
var notifyAction = new SNC.NotifyAction();

// add a queue
var queue = notifyAction.addQueue();
queue.setName('myQueueName');
queue.setDequeue(false);

// serialize to json
var json = notifyAction.toJson();
gs.log('serialization result: ' + json);

// instantiate a new notify action
var newAction = new SNC.NotifyAction();

// deserialize the json generated above
newAction.fromJson(json);

// serialize the new object and log the result
newJson = newAction.toJson();
gs.log('new serialization result: ' + newJson);
gs.log('the same: ' + (json == newJson));

Output: *** Script: serialization result: {"fClassName":"NotifyAction","fActions":[{"fClassName":"QueueAction","fDequeue":true,"fQueueName":"myQueueName"}]} *** Script: new serialization result: {"fClassName":"NotifyAction","fActions":[{"fClassName":"QueueAction","fDequeue":true,"fQueueName":"myQueueName"}]} *** Script: the same: true