This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!

Introduction

Here we will learn CTI IVR Integration with ServiceNow.Below are the details:

  1. The CTI IVR Integration would validate the user Caller ID and/or Employee ID by querying the ServiceNow User table for a required match.
  2. The IVR Server would send the Caller ID and/or Employee ID to ServiceNow as a SOAP request.
  3. The request parameters would be initially checked whether the data format is correct.
  4. If the data format is found to be incorrect a {phone / employee number} “_WRONG_FORMAT” response would be sent.
  5. If the data format is found to be correct then the same would be used to query the ServiceNow user table to find the matching employee/non-employee.
  6. If a suitable match is found a {phone / employee number} “_MATCH” response would be sent else {phone / employee number} “_NOMATCH” response would be sent.

Scripted SOAP service - CTIIVRIntegration

To achieve the CTI IVR integration with ServiceNow, a scripted SOAP service is configured which does the employee number and phone number format validation. Once the validation is success the same would be used to query the ServiceNow user table to find a matching employee / non-employee. Suitable response code is sent once the validation is done as well as the employee check is done.

  • Name: CTIIVRIntegration
  • WSDL: https://dev64666.service-now.com/CTIIVRIntegration.do?WSDL CTI Integration06052020.PNG

Script:

(function scriptedWebServiceOperation(request, response) {

	// Add your code here 
	var phone = request.phone;
	var empNum = request.employee_number;
	var empStatus;
	var phStatus;
	var eNumFormat;
	var phoneFormat;
	


	//validate employee number as 9 digit
	var length = empNum.toString().length;
	if(empNum != null && empNum != '' && length == 9 && (empNum.charCodeAt(0)==78 || (empNum.charCodeAt(0)>47 && empNum.charCodeAt(0)<58))){
		eNumFormat = "Success";		
	}
	else{
		response.empFormatStatus = empNum+"_WRONG_FORMAT";
	}
	
	//validate user phone number
	var format = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
	
	if(format.test(phone)==true){
		response.phoneFormatStatus = phone+"_WRONG_FORMAT";
	}
	else{
		phoneFormat = "Success";
	}
	
	
	if (phoneFormat=="Success"){
       phStatus = validateUser("phone",phone);
		if(phStatus=="Success")
			response.phoneStatus = phone+"_MATCH";
		else
			response.phoneStatus = phone+"_NOMATCH";
    }
	
	


	if (eNumFormat=="Success" || phStatus!="Success"){
       empStatus = validateUser("employee_number",empNum);
		if(empStatus=="Success")
			response.empStatus = empNum+"_MATCH";
		else
			response.empStatus = empNum+"_NOMATCH";
    }	
	
function validateUser(field,value){
	var userGr = new GlideRecord("sys_user");
	if(field=="phone"){
		var userGr1 = userGr.addQuery(field,value);
		userGr1.addOrCondition("mobile_phone",value);
	}
	else{
		userGr.addQuery(field,value);
	}
	userGr.query();
	if(userGr.next()){
		return 'Success';
	}
	else{
		return 'Error';
	}
}
})(request, response);

Input Parameters:

CTI Integration060520204.PNG

phone: The CallerID as received in ServiceNow from IVR server • employee_number: The employee / non-employee number as received from IVR server

Output Parameters:

CTI Integration060520202.PNG

phoneStatus: The output parameter that contains either {phone} “_MATCH” or {phone} “_NOMATCH” status. • empStatus: The output parameter that contains either {employee_number} “_MATCH” or {employee_number} “_NOMATCH” status. • phoneFormatStatus: The output parameter that contains {phone} “_WRONG_FORMAT” status if format is not valid. • empFormatStatus: The output parameter that contains {employee_number} “_WRONG_FORMAT” status if format is not valid.

Authentication Profile

A service account is configured at the ServiceNow end with “soap” role to authenticate the integration. The Details is as below:

  • User ID: ctiintegration_user
  • Active: true
  • Web service access only: true
  • Password: 123
  • Parent Role: soap
    Content