Automatic Notifications
Bright Pattern campaigns can be used with ServiceNow business rules to send voice and text notifications to affected users. To create automatic notifications for incidents, do the following:
- Create a notification list.
- Create a notification campaign (voice/SMS).
- Create a Business Rule on the ServiceNow instance.
Procedure
1. Create a Notification List
In the Contact Center Administrator application, section Lists, create a list that will be used for automatic notifications. The contents of the list are determined per customer needs, but it is recommended to at least include the following fields:
- first name
- last name
- phone number
- ticket number
- message
By using the combination of ticket number and message as the key, new messages will be sent for the same user and ticket, and new messages will be sent for the same user with different tickets even if the message is the same.
2. Create a Notification Campaign
Create an outbound campaign for notifications (link it). If both voice and sms are to be used, you will need to create both an outbound voice campaign and an outbound messaging campaign
3. Create Business Rules
Create a business rule on the ServiceNow instance that has the triggers and information needed for the notification. The following is an example for incidents when they are created or updated:
(function executeRule(current, previous /*null when async*/) {
var number = current.number;
var caller_id = current.caller_id;
var grUser = new GlideRecord('sys_user');
grUser.get(caller_id);
var first_name = grUser.getValue('first_name');
var last_name = grUser.getValue('last_name');
var phone = grUser.getValue('phone');
var message = "an incident has been created or updated";
var record_string = number + "," + first_name + "," + last_name + "," + phone + "," + message;
var tok_str = "client_id=user-id&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&scope=xyz.brightpattern.com&grant_type=client_credentials";
var sm = new sn_ws.RESTMessageV2();
sm.setHttpMethod('post');
sm.setEndpoint('https://xyz.brightpattern.com/configapi/v2/oauth/token');
sm.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
sm.setRequestBody(tok_str);
var res = sm.execute();
var access_tok = JSON.parse(res.getBody()).access_token;
sm.setEndpoint("https://xyz.brightpattern.com/configapi/v2/callinglist/add/snl");
sm.setHttpMethod('post');
sm.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
sm.setRequestHeader('Authorization', 'Bearer' + access_tok);
var rec_str = "number=" + number + "&first_name=" + first_name + "&last_name=" + last_name + "&phone=1" + phone + "&message=this is an update from sn2";
sm.setRequestBody(rec_str);
res = sm.execute();
})(current, previous);
This script will get the information needed to update the list that was configured previously. Then, it will get authorization to use the Bright Pattern List Management API, and send a request to add a new record to the list. When a new record is added to a running campaign, it will be picked up by Bright Pattern Contact Center (BPCC) software and sent out.
The following script is another business rule that runs on the change_request table. Instead of firing on any update, the trigger is when the state changes to the authorize state specifically. This is because its purpose is to send a voting notification to the CAB.
(function executeRule(current, previous /*null when async*/) {
var tok_str = "client_id=user&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&scope=xyz.brightpattern.com&grant_type=client_credentials";
var sm = new sn_ws.RESTMessageV2();
sm.setHttpMethod('post');
sm.setEndpoint('https://ch.brightpattern.com/configapi/v2/oauth/token');
sm.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
sm.setRequestBody(tok_str);
var res = sm.execute();
var access_tok = JSON.parse(res.getBody()).access_token;
var chg_id = current.sys_id;
var grApp = new GlideRecord('sysapproval_approver');
var bRet = grApp.get('sysapproval', chg_id);
while(bRet){
var grUser = new GlideRecord('sys_user');
var userId = grApp.getValue('approver');
grUser.get(userId);
if(grUser.getValue('phone')){
var first_name = grUser.getValue('first_name');
var last_name = grUser.getValue('last_name');
var phone = grUser.getValue('phone');
phone = phone.replace('(','');
phone = phone.replace(')','');
phone = phone.replace('-','');
phone = phone.replace(' ','');
var message = current.number + " needs your approval or denial, "+ first_name + " " + last_name + ", " + " . Please respond to this message to proceed with: " + current.number + ":YES/NO for automatic voting";
var record_string = current.number + "," + first_name + "," + last_name + "," + phone + "," + message;
sm.setEndpoint("https://xyz.brightpattern.com/configapi/v2/callinglist/add/snl");
sm.setHttpMethod('post');
sm.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
sm.setRequestHeader('Authorization', 'Bearer' + access_tok);
var rec_str = "number=" + current.number + "&first_name=" + first_name + "&last_name=" + last_name + "&phone=1" + phone + "&message=" + message;
sm.setRequestBody(rec_str);
res = sm.execute();
}
bRet = grApp.next();
}
})(current, previous);
Like the other script, this script will send a record to the notification list in BPCC that is configured to run on the notification campaign. The message sent will allow the user to reply with the ticket number and YES or NO in order to complete their portion of the process.