Notify - Global

The Notify API allows you to interact with Notify calls and SMS messages using scripts.

Notify - call(String notifyPhoneNumber, String toPhoneNumber)

Make a call to an E.164-compliant phone number.

Table 1. Parameters
Name Type Description
notifyPhoneNumber String The phone number to make the call from. This number appears as the caller ID.
toPhoneNumber String The phone number to call.
Table 2. Returns
Type Description
void

var from = '+14048007337';
var to = '+31646810495';

// set up call
new SNC.Notify().call(from, to);

Notify - call(String notifyPhoneNumber, String toPhoneNumber, GlideRecord conferenceCall)

Call a number to add that number to an active conference call.

This method is intended specifically for conference calls. To initiate calls between only two participants, use the call(String notifyPhoneNumber, String toPhoneNumber) method instead.

Table 3. Parameters
Name Type Description
notifyPhoneNumber String The Notify phone number to make the call from. When you initiate a call, the outgoing call workflow for the number group associated with this number runs. Ensure this workflow includes a join conference call activity to connect the user to the conference call.
toPhoneNumber String The phone number to call. Called numbers are added to the conference call.
conferenceCall GlideRecord A GlideRecord for the Notify Call [notify_call] table identifying the conference call record. This record is automatically added to the outgoing call workflow scratchpad as the workflow.scratchpad.conference_call variable.
Table 4. Returns
Type Description
void
var notify = new SNC.Notify();
var from = '+14041234567';
var participants = ['+31612345678', '+31623456789', '+31687654321'];

// set up a conference call
var conferenceCall = notify.conferenceCall();

// set up the outbound calls for all conference call participants
for (var i in participants) {
    var to = participants[i];
    notify.call(from, to, conferenceCall);
}

// feedback
gs.log(gs.getMessage('set up a conference call with number {0} and (re)join code: {1}', 
    [ conferenceCall.getValue('number'), conferenceCall.getValue('code') ]));

Notify - conferenceCall()

Create a new conference call GlideRecord.

Table 5. Parameters
Name Type Description
None
Table 6. Returns
Type Description
GlideRecord A new Notify Call [notify_call] record for a conference call.
var notify = new SNC.Notify();
var from = '+14041234567';
var participants = ['+31612345678', '+31623456789', '+31687654321'];

// set up a conference call
var conferenceCall = notify.conferenceCall();

// set up the outbound calls for all conference call participants
for (var i in participants) {
    var to = participants[i];
    notify.call(from, to, conferenceCall);
}

// feedback
gs.log(gs.getMessage('set up a conference call with number {0} and (re)join code: {1}', 
    [ conferenceCall.getValue('number'), conferenceCall.getValue('code') ]));

Notify - dequeueCall(GlideRecord callRecord)

Resume a call after it was put in a queue.

Use this method to resume calls that were put in a queue with the queueCall method.

Table 7. Parameters
Name Type Description
callRecord GlideRecord A GlideRecord object on the Notify Call [notify_call] table with the held call you want to resume.
Table 8. Returns
Type Description
void
var call = new GlideRecord('notify_call');
call.get('some sys_id');
if (call.isValid()) {
    new SNC.Notify().dequeueCall(call);
}

Notify - forwardCall(GlideRecord call, String destination, String dtmf)

Forward a call to connect that call with a different recipient.

Table 9. Parameters
Name Type Description
call GlideRecord or String A Notify call record, or the telephony provider call ID.
destination GlideRecord or String A Notify phone number record, or an E.164-compliant phone number.
dtmf String A DTMF code to play upon connection.
Table 10. Returns
Type Description
void


      
    

Notify - getAvailableClients(String notifyNumber)

Get a list of client sessions that are available to receive calls.

Table 11. Parameters
Name Type Description
notifyNumber String Any valid Notify phone number.
Table 12. Returns
Type Description
Array An array of JSON objects with the following format:
[{
    sys_id: "...",  // user's sys_id
    name: "..." // user's name
}]


      
    

Notify - getChildCallIDs(GlideRecord callRecord)

Get the sys_id values of calls that are children of a specified call.

Any call started by forwarding another call, such as with the Forward workflow activity, is considered a child of the original call. The original call is the parent call.

Table 13. Parameters
Name Type Description
callRecord GlideRecord A record on the Notify Call [notify_call] table.
Table 14. Returns
Type Description
Array The sys_id values of all calls that are children of the specified call.

var callRecord = new GlideRecord('notify_call');
callRecord.get("0f4f5863ff13310014ecffffffffff28");

var notify = new SNC.Notify();
var childCallIDs = notify.getChildCallIDs(callRecord);

for(var callID in childCallIDs)
//perform any operations with the child callID values

Notify - getParentCallID(GlideRecord callRecord)

Get the sys_id of a specified call's parent call.

Any call started by forwarding another call, such as with the Forward workflow activity, is considered a child of the original call. The original call is the parent call.

Table 15. Parameters
Name Type Description
callRecord GlideRecord A record on the Notify Call [notify_call] table.
Table 16. Returns
Type Description
String The sys_id of the parent call record.

var callRecord = new GlideRecord('notify_call');
callRecord.get("0f4f5863ff13310014ecffffffffff28");

var notify = new SNC.Notify();
var parentCallID = notify.getParentCallID(callRecord);

Notify - getPhoneNumbers()

Get all phone numbers and short codes available to Notify, as an array.

Table 17. Parameters
Name Type Description
None
Table 18. Returns
Type Description
Array An array of NotifyPhoneNumber objects, each object representing one phone number available to Notify.

// instantiate notify
var notify = new SNC.Notify();

// get all available phone numbers
var phoneNumbers = notify.getPhoneNumbers();

// iterate over phone numbers
for (var i = 0; i < phoneNumbers.size(); i++) {

var number = phoneNumbers.get(i);

//perform any actions using each phone number

}

Notify - getTokens()

Get client tokens for any installed telephony drivers for use in WebRTC or mobile clients.

This function uses the currently logged-in user record as the client.

Table 19. Parameters
Name Type Description
None
Table 20. Returns
Type Description
String The client tokens, as a JSON string.

// get Notify Client Tokens per active Notify Driver for the currently logged in user
var json = new SNC.Notify().getTokens();

// parse the json that was return into a tokens object
var tokens = JSON.parse(json);

// log line
gs.log('Notify Client Tokens for the currenty logged in user');

// iterate over the driver tokens
for (var driver in tokens) {
    gs.log(driver + ' Driver token: ' + tokens[driver]);
}

Output:

Notify - getTokens(GlideRecord record)

Get client tokens for any installed telephony drivers for use in WebRTC or mobile clients.

Table 21. Parameters
Name Type Description
record GlideRecord A record used to generate the client tokens.
Table 22. Returns
Type Description
String The client tokens. The value of the string depends on the GlideRecord parameter.

This example demonstrates getting Notify client tokens for every Notify group.

// instantiate Notify
var notify = new SNC.Notify();

// get all Notify Groups
var notifyGroup = new GlideRecord("notify_group");
notifyGroup.query();

// iterate over all notify groups
while (notifyGroup.next()) {
    // generate Notify Client tokens per active Notify Driver for this group
    var json = notify.getTokens(notifyGroup);
    var tokens = JSON.parse(json);

    for (var driver in tokens) {
        gs.log(gs.getMessage("Notify Client token for {0} driver and Notify Group '{1}': {2}", [driver, notifyGroup.getValue('name'), tokens[driver]]));
    }
}

Notify - kick(GlideRecord participant)

Kick a specified user from a Notify conference call.

Table 23. Parameters
Name Type Description
participant GlideRecord A GlideRecord object containing the Notify Participant [notify_participant] to kick from the conference call.
Table 24. Returns
Type Description
void

var participant = new GlideRecord('notify_participant');
participant.get('<sys_id>');
if (participant.isValid()) {
    new SNC.Notify().kick(participant);
}

Notify - queueCall(GlideRecord callRecord)

Put a call into a queue.

Resume a queued call using the dequeueCall method.

Table 25. Parameters
Name Type Description
callRecord GlideRecord A GlideRecord object on the Notify Call [notify_call] table with the call you want to put on hold.
Table 26. Returns
Type Description
void
var call = new GlideRecord('notify_call');
call.get('<call record sys_id>');
if (call.isValid()) {
    new SNC.Notify().queueCall(call);
}

Notify - sendSMS(NotifyPhoneNumber notifyPhoneNumber, String toPhoneNumber, String messageBody)

Send an SMS text message to an E.164-compliant phone number.

This function creates a new record on the Notify Message [notify_message] table.

Table 27. Parameters
Name Type Description
notifyPhoneNumber NotifyPhoneNumber The Notify phone number or short code to send this SMS from.
toPhoneNumber String An E.164-compliant phone number to send the SMS to.
messageBody String The SMS text.
Table 28. Returns
Type Description
String The sys_id of the Notify Message [notify_message] record created by this function.


      
    

Notify - sendSMS(NotifyPhoneNumber notifyPhoneNumber, String toPhoneNumber, String messageBody, GlideRecord source)

Send an SMS text message to an E.164-compliant phone number.

This function creates a new record on the Notify Message [notify_message] table and associates it with the source record.

Table 29. Parameters
Name Type Description
notifyPhoneNumber NotifyPhoneNumber The Notify phone number or short code to send this SMS from.
toPhoneNumber String An E.164-compliant phone number to send the SMS to.
messageBody String The SMS text.
source GlideRecord The source record that prompted this SMS message, such as an incident.
Table 30. Returns
Type Description
String The sys_id of the Notify Message [notify_message] record created by this function.