Legacy Notify API - Global

The legacy Notify API provides functionality for sending emails, sending SMS messages, and setting up conference calls.

Use this when you want to use Notify functionality with applications on your system.
Note: This API is included with the legacy Notify functionality. For APIs included in the current Notify feature, see the Notify, NotifyAction, NotifyPhoneNumber, and NotifyClient APIs.

NotifyNow - addConferenceCallParticipant(String conferenceCall, String participant)

Add ad-hoc users to an ongoing conference call.

When the method is called with a phone number for the participant parameter and there is exactly one sys_user record that matches the phone number, that sys_user record will be related to the participant. The participant's phone number field will be left blank because the phone number is in the sys_user record. If there are several sys_user records that match the phone number, or if there are no results, the participant's phone number field will be filled in, and there will be no stored reference to sys_user because the user is not known.

Table 1. Parameters
Name Type Description
conferenceCall String or GlideRecord The sys_id or GlideRecord of an active conference call.
participant String or GlideRecord The sys_id or GlideRecord of a user with an E.164-compliant phone number, or an E.164-compliant phone number.
Table 2. Returns
Type Description
GlideRecord The participant record of the new participant that was added to the conference call.

// add a new participant by conference call sys_id (string) and phone number (string) 
var nn = new SNC.NotifyNow();
gs.log(nn.addConferenceCallParticipant('d193b242eb020100a04d4910f206fe39', '+31612345678'));

// add a new participant by conference call sys_id (string) and user record (GlideRecord)
var user = new GlideRecord('sys_user');
user.query('user_name', 'myUserName');
if (user.hasNext() && user.next()) {
    var nn = new SNC.NotifyNow();
    gs.log(nn.addConferenceCallParticipant('d193b242eb020100a04d4910f206fe39', user));
 
    // you could have added the user by sys_id as well:
    // nn.addConferenceCallParticipant('d193b242eb020100a04d4910f206fe39', user.getValue('sys_id'));
} else {
    gs.log('no such user');
}

// add a new participant by conference call record (GlideRecord) and phone number (string)
var conferenceCall = new GlideRecord('notifynow_conference_call');
conferenceCall.query('title', 'IA0001001');
if (conferenceCall.hasNext() && conferenceCall.next()) {
    var nn = new SNC.NotifyNow();
    gs.log(nn.addConferenceCallParticipant(conferenceCall, '+31612345678'));
} else {
    gs.log('no such conference call');
}

NotifyNow - convertLocalPhoneNumberToE164(String userID, String phoneNumber)

Convert a local phone number to an E.164-compliant phone number based on a user's location.

Table 3. Parameters
Name Type Description
userID String The sys_id of a sys_user record to get location information from.
phoneNumber String The phone number.
Table 4. Returns
Type Description
String The E.164-compliant phone number.

var localPhoneNumber = '01784 221600';
var userName = 'Heath Vanalphen';
 
var user = new GlideRecord('sys_user');
user.get('name',userName);
var E164Number = new SNC.NotifyNow().convertLocalPhoneNumberToE164(user.getUniqueValue(), localPhoneNumber);
gs.log('converted: ' + localPhoneNumber + ' to ' + E164Number + ' based on ' + user.getValue('name') + 
     '\'s location (' + user.getValue('location') + ')');

NotifyNow - getConferenceCallParticipants(String conferenceCallId, Boolean isCallable)

Get all participants for a conference call.

Table 5. Parameters
Name Type Description
conferenceCallId String The ID of the conference call.
isCallable Boolean An optional flag to return either only the users you can call (true) or those you cannot call (false).
Table 6. Returns
Type Description
GlideRecord The participants

var nn = new SNC.NotifyNow();
var user = nn.getConferenceCallParticipants('c2e91710eb120100f34087b9d106fe37');
 
while (user.hasNext() && user.next()) {
    if (user.getValue('participant')) {
        gs.log('user: ' + user.getValue('sys_id'));
    } else {
        gs.log('phone number: ' + user.getValue('phone_number'));
    }
}

var nn = new SNC.NotifyNow();
var user = nn.getConferenceCallParticipants('c2e91710eb120100f34087b9d106fe37', true);
 
while (user.hasNext() && user.next()) {
    if (user.getValue('participant')) {
        gs.log('user: ' + user.getValue('sys_id'));
    } else {
        gs.log('phone number: ' + user.getValue('phone_number'));
    }
}

var conferenceCallId = '32b11430eb1201003cf587b9d106feb8';
 
// get all participants
gs.log('all conference call participants:');
var nn = new SNC.NotifyNow();
var user = nn.getConferenceCallParticipants(conferenceCallId);
gs.log(user);
 
// get all callable participants
gs.log('all conference call participants we can call:');
user = nn.getConferenceCallParticipants(conferenceCallId, true);
gs.log(user);
 
// get all un callable participants
gs.log('all conference call participants that are already in an active session and whom we cannot call:');
user = nn.getConferenceCallParticipants(conferenceCallId, false);
gs.log(user);

NotifyNow - getFrequentlyCalledUsers(Number limit)

Return a number of frequently-called users, up to the limit parameter, in alphabetical order.

Table 7. Parameters
Name Type Description
limit Number The maximum number of results.
Table 8. Returns
Type Description
GlideRecord The frequently called users in alphabetical order.

var nn = new SNC.NotifyNow();
var fc = nn.getFrequentlyCalledUsers(10);
 
while (fc.hasNext() && fc.next()) {
    gs.log("got user " + fc.getValue('name') + ' - ' + fc.getValue('sys_id'));
}

NotifyNow - getPreferredE164SMSNumber(GlideRecord user)

Get a user's preferred E.164-compliant phone number for SMS messages.

Table 9. Parameters
Name Type Description
user GlideRecord or String The user record or the sys_id of a user to get the E.164-compliant phone number from.
Table 10. Returns
Type Description
String The E.164-compliant phone number or null.

var userID = "<user sys_id>";
var E164Number = new SNC.NotifyNow().getPreferredE164SMSNumber(userID);
gs.log('the preferred phone number for sending SMS notifications is ' + E164Number + ' for user with id: ' + userID);

NotifyNow - getPreferredE164VoiceNumber(GlideRecord user)

Get a user's preferred E.164-compliant phone number for voice calls.

Table 11. Parameters
Name Type Description
user GlideRecord or String The user record or the sys_id of a user to get the E.164-compliant phone number from.
Table 12. Returns
Type Description
String The E.164-compliant phone number or null.

var userID = "<user sys_id>";
var E164Number = new SNC.NotifyNow().getPreferredE164VoiceNumber(userID);
gs.log('the preferred phone number for setting up voice calls is ' + E164Number + ' for user with id: ' + userID);

NotifyNow - getPreferredEmailAddress(GlideRecord user)

Get a user's preferred email address

Table 13. Parameters
Name Type Description
user GlideRecord or String The user record or the sys_id of a user to get the email address from.
Table 14. Returns
Type Description
String The email address or null.

var userID = "some user sys id";
var email = new SNC.NotifyNow().getPreferredEmailAddress(userID);
gs.log('the preferred email address for sending email notifications is ' + email + ' for user with id: ' + userID);

NotifyNow - getReadyState()

Indicate whether Notify is set up correctly or not.

This method can only be accessed by administrators or users with the notifynow_admin role. Users with all other roles get the message False when trying to run the function in a script.

Table 15. Parameters
Name Type Description
None
Table 16. Returns
Type Description
Boolean True if Notify is set up correctly, otherwise false.

var nn = new SNC.NotifyNow();
gs.log(((nn.getReadyState()) ? "OK" :  "NOT OK"));

NotifyNow - getStatus()

Get the current status of Notify configuration.

This method can only be accessed by administrators or users with the notifynow_admin role. Users with all other roles get the message Unauthorized when trying to run the function in a script.

Table 17. Parameters
Name Type Description
None
Table 18. Returns
Type Description
String One of the possible status messages.
Status Description
NO_NUMBER_MESSAGE The account does not have a telephone number set up. Ensure that you set up the telephone number for the account.
NO_ENDPOINTS_MESSAGE The account does not have its endpoints set up correctly. Ensure that you set up the endpoints for the account.
ACCOUNT_OK_MESSAGE The account is active and ready for use.
ACCOUNT_NO_AUTH The Twilio AuthToken is not valid.
ACCOUNT_NOT_CONFIGURED The Twilio AccountSID or AuthToken is not valid.

var nn = new SNC.NotifyNow();
gs.log(nn.getStatus());

NotifyNow - initiateConferenceCall(String[] conferenceCallParticipants, String conferenceCallTitle)

Initiate a new conference call.

Table 19. Parameters
Name Type Description
conferenceCallParticipants String One or more users, conference call participants, identified by the sys_ids from the sys_user table or E.164-compliant phone numbers.
conferenceCallTitle String Title of the conference call. This parameter has a maximum length of 40 characters.
Table 20. Returns
Type Description
GlideRecord The conference call record, or null if there was an error.

This initiates a conference call with E.164-compliant phone numbers for participants, without the optional source record parameter and and does not send any conference call details via SMS or email.

var participants = ['+31205655548', '+31205655552', '+31652825393'];
// set up conference call
var nn = new SNC.NotifyNow();
var conferenceCall = nn.initiateConferenceCall(participants, "testing12");
gs.log('started conference call: ' + conferenceCall.getUniqueValue());

NotifyNow - initiateConferenceCall(String[] conferenceCallParticipants, String conferenceCallTitle, GlideRecord sourceRecord, Boolean private)

Initiate a new conference call.

Table 21. Parameters
Name Type Description
conferenceCallParticipants String One or more users, conference call participants, identified by the sys_ids from the sys_user table or E.164-compliant phone numbers.
conferenceCallTitle String Title of the conference call. This parameter has a maximum length of 40 characters.
sourceRecord GlideRecord Source record to associate to the conference call such as an incident or problem number.
private Boolean Value to control if a conference call is private. This value defaults to false.
Table 22. Returns
Type Description
GlideRecord The conference call record, or null if there was an error.

This initiates a conference call with participants that have a E.164-compliant phone number and participants from the sys_user table and sends conference call details via SMS and email to all participants.

// define phone number participants
var participants = ['+31205655548', '+31205655552', '+31652825393'];
 
// we also want to add two Dutch sys_user participants
var user = new GlideRecord('sys_user');
user.addNotNullQuery('mobile_phone');
user.addQuery('mobile_phone', 'STARTSWITH', '+316');
user.setLimit(2);
user.query();
 
// add users to the participant array
while (user.hasNext() && user.next()) {
	gs.log('adding user ' + user.getValue('name') + ' with phone number ' + 
             user.getValue('mobile_phone') + ' to the participant array');
	participants.push(user.getUniqueValue());
}
 
// define a source record to associate with the conference call
var source = new GlideRecord("cmdb_ci");
source.query("asset_tag", "P1000167");
if (source.hasNext() && source.next()) {
	// set up conference call
	var nn = new SNC.NotifyNow();
	var conferenceCall = nn.initiateConferenceCall(participants, "testing 1 2", source);
 
	// check if the conference call was successfully created
	if (conferenceCall != null) {
		gs.log('started conference call: ' + conferenceCall.getUniqueValue());
	} else {
		gs.log('could not start the conference call :(');
	}
}

NotifyNow - isCallable(String participant)

Determine whether a user is callable or not.

A user must have a valid phone number to be callable. A user who is already in an active session is not callable.

Table 23. Parameters
Name Type Description
participant String or GlideRecord A sys_user or notifynow_participant record, or an E.164-compliant phone number.
Table 24. Returns
Type Description
boolean Whether this participant can be called or not.

var nn = new SNC.NotifyNow();
gs.log('by number: ' + nn.isCallable('+31612345678'));
 
var user = GlideRecord('sys_user');
user.query('sys_id', '13d39544eb5201003cf587b9d106fea9');
if (user.hasNext() && user.next())
  gs.log('by user: ' + nn.isCallable(user));
 
var participant = GlideRecord('notifynow_participant');
participant.query('sys_id', '33b11430eb1201003cf587b9d106feb9');
if (participant.hasNext() && participant.next())
  gs.log('by participant: ' + nn.isCallable(participant));

NotifyNow - isSMSCapable()

Check if the telephone number associated with the Twilio account is capable of sending SMS messages.

Table 25. Parameters
Name Type Description
None
Table 26. Returns
Type Description
Boolean Whether the telephone number associated with the Twilio account is capable of sending SMS messages.

gs.log('The twilio number is SMS capable: ' + ((new SNC.NotifyNow().isSMSCapable()) ? 'yes' : 'no'));

NotifyNow - isSMSCapable(String userID)

Check if a user is able to send SMS messages.

Table 27. Parameters
Name Type Description
userID String The sys_id of the user you want to check for an SMS-capable phone number.
Table 28. Returns
Type Description
Boolean If the user can send SMS messages.

gs.log('the user is able to send SMS messages (e.g. has a SMS device): ' + ((new SNC.NotifyNow().isSMSCapable('<user sys_id>')) ? 
     'yes' : 'no'));

NotifyNow - isVoiceCapable()

Check if the telephone number associated with the Twilio account is capable of setting up phone calls.

Table 29. Parameters
Name Type Description
None
Table 30. Returns
Type Description
Boolean Whether the telephone number associated with the Twilio account is capable of setting up phone calls.

gs.log('the Twilio number is Voice capable: ' + ((new SNC.NotifyNow().isVoiceCapable()) ? 'yes' : 'no'));

NotifyNow - isVoiceCapable(String userID)

Check if a user is able to make voice calls.

Table 31. Parameters
Name Type Description
userID String The sys_id of the user you want to check for a voice-call capable phone number.
Table 32. Returns
Type Description
boolean Whether the user has a voice-call capable phone number.

gs.log('the user is able to send SMS messages (e.g. has a SMS device): ' + 
     ((new SNC.NotifyNow().isVoiceCapable('someuserid')) ? 'yes' : 'no'));

NotifyNow - kick(GlideRecord participant)

Remove a participant from a conference call.

Table 33. Parameters
Name Type Description
participant GlideRecord The conference call participant to remove from the call.
Table 34. Returns
Type Description
Boolean True if the participant was removed, otherwise false.

var participantId = "<participant sys_id>";
var participant = new GlideRecord('notifynow_participant');
participant.get(participantId);
if (participant.isValid()) {
     // kick participant
     result = new SNC.NotifyNow().kick(participant);
     gs.log('participant kicked: ' + result);
}

NotifyNow - mute(GlideRecord participant)

Mute a participant on a conference call.

Table 35. Parameters
Name Type Description
participant GlideRecord The conference call participant to mute.
Table 36. Returns
Type Description
Boolean True if the participant was muted, otherwise false.

var participantId = "<participant sys_id>";
var participant = new GlideRecord('notifynow_participant');
participant.get(participantId);
if (participant.isValid()) {
     // mute participant
     result = new SNC.NotifyNow().mute(participant);
     gs.log('participant muted: ' + result);
}

NotifyNow - sendEmailQuestion(String emailAddress, String question, GlideRecord sourceRecord, String emailSubject)

Send an email question to an email address.

The sendEmailQuestion method produces a question body and requires users to click a link to indicate their choice.

Table 37. Parameters
Name Type Description
emailAddress String Email address to send the question to.
question String or GlideRecord The question record to send or the sys_id of a question record.
sourceRecord GlideRecord An optional source record to associate to the SMS question, such as an incident.
emailSubject String Optional text to override the default email subject.
Table 38. Returns
Type Description
String The conversation sys_id.

This example demonstrates using the default email subject.

var user = GlideRecord("sys_user");
user.get("email", "someone@somedomain.com");
 
new SNC.NotifyNow().sendEmailQuestion(user.getValue('email'), "b6b34500bf3111003cf585ce2c0739ce", user);

This example uses dot-walking and specifies a source record and email subject.

new SNC.NotifyNow().sendEmailQuestion("someone@somedomain.com", "b6071733bf1111003cf585ce2c07390f", current, 
        "Please answer this question");

This example uses dot-walking and specifies an email subject but no source record.

new SNC.NotifyNow().sendEmailQuestion("someone@somedomain.com", "b6071733bf1111003cf585ce2c07390f", 
        "Please answer this question");

NotifyNow - sendSMS(String phoneNumber, String smsBody)

Sends an SMS message to an E.164-compliant mobile phone number.

Notify supports international numbers. Using this method with a number that does not support sending SMS messages results in an error being logged.

Table 39. Parameters
Name Type Description
phoneNumber String The E.164-compliant phone number to send the message to.
smsBody String The message to send, maximum 1600 characters.
Table 40. Returns
Type Description
void

new SNC.NotifyNow().sendSMS("+31612345678", "This is a message without source record");

NotifyNow - sendSMS(String phoneNumber, String smsBody, GlideRecord source)

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

Notify supports international numbers. Using this method with a number that does not support sending SMS messages results in an error being logged.

Table 41. Parameters
Name Type Description
phoneNumber String The E.164-compliant phone number to send the message to.
smsBody String The message to send, maximum 1600 characters.
source GlideRecord The source record to associate with this SMS message.
Table 42. Returns
Type Description
void

var source = new GlideRecord("my_table");
source.query("my_field", "my_value");

if (source.hasNext() && source.next()) {
    // send a text message
    var nn = new SNC.NotifyNow();
    var message = "this is just a test";
    var number = "+31612345678";
    nn.sendSMS(number, message, source);
}

This example uses dot-walking and the current record as the source record.

new SNC.NotifyNow().sendSMS("+31612345678", "this is a test", current);

NotifyNow - sendSMSQuestion(String phoneNumber, String question, GlideRecord sourceRecord)

Send an SMS question.

Table 43. Parameters
Name Type Description
phoneNumber An E.164-compliant phone number to send the message to.
question String or GlideRecord The question record to send or the sys_id of a question record.
sourceRecord An optional source record to associate to the SMS question, such as an incident.
Table 44. Returns
Type Description
String The conversation sys_id, or null if the SMS was not sent successfully.

var question = new GlideRecord("notifynow_question");
question.query();
 
// get the first question
if (question.hasNext() && question.next()) {
	// send the sms question
        var number = "+31612345678";
	var nn = new SNC.NotifyNow();
	nn.sendSMSQuestion(number, question.getUniqueValue(), current);
}

NotifyNow - umute(GlideRecord participant)

Unmute a participant on a conference call.

Table 45. Parameters
Name Type Description
participant GlideRecord The muted conference call participant to unmute.
Table 46. Returns
Type Description
Boolean True if the participant was unmuted, otherwise false.

var participantId = "<participant sys_id>";
var participant = new GlideRecord('notifynow_participant');
participant.get(participantId);
if (participant.isValid()) {
     // unmute participant
     result = new SNC.NotifyNow().unmute(participant);
     gs.log('participant unmuted: ' + result);
}