BUY

CommuniGate Pro Business Application Integrations

Integration of CommuniGate Pro Contact Center with the "OSticket" Ticketing support system.

While receiving an incoming call, the Contact Center Agent is getting the customers data record card with all the information from ticketing system displayed conviently.

Below is a script that sends 'http calls' to the OSTicket system to get the information about the caller.

// ================================================== //
//   Contact Center integration with osTicket CRM     //
//                   Version 2.0                      //
// ================================================== //

function  consultCRM(finalAttempt)       forward;
function  requestCRM(cookie,qParam)      forward;

var monitorSettings;

function ccOsTicketCRM() {
	return consultCRM(false);
}

function consultCRM(finalAttempt) {
	var qParam = EmailUserPart(SIPURItoEmail(RemoteURI()));
	var cookie = GetAccountPreferences("~" + MyEmail() + "/CRMCookie");
	var result;
	if(!IsString(cookie)) {
		result = requestCRM(null,null);        // login to the osTicket CRM
		if(IsDictionary(result) && result.responseCode < 400) {
			cookie = result.("Set-Cookie");
			if(IsString(cookie)) {
				cookie = cookie.subString(0,cookie.findSubString(";"));
				void(ExecuteCLI("UpdateAccountPrefs " + MyEmail() + " {CRMCookie=\"" + cookie + "\";}") != null);
			} else {return null;}
		} else {return null;}
	}
		
	result = requestCRM(cookie,qParam);       // request customer card using stored session 'cookie' value
	if(IsDictionary(result)) {
		if(result.responseCode < 400 && IsData(result.body)) {
			var crmResult = Convert(result.body,result.charset);
			return IsString(crmResult) ? JSONToObject(crmResult) : null;
		} else {  // perhaps the 'cookie' value has expired, try to login and request the customer card one more time
			if(!finalAttempt) {
				void(ExecuteCLI("UpdateAccountPrefs " + MyEmail() + " {CRMCookie=#NULL#;}") != null);
				return consultCRM(true);    
			} else {return null;}
		}
	}
	return null;
}

function requestCRM(cookie,qParam) {
	var url = monitorSettings.iFrameUrl + (qParam == null ? "login.php" : "ajax.php/users/local?q=" + String(qParam));
	var params     = NewDictionary();
	params.method  = qParam == null ? "POST" : "GET";
	params.Cookie  = IsString(cookie) ? cookie : null;
	params.timeout = 2;
	if(qParam == null) {                  // login to the osTicket CRM with 'user'/'password' credentials
		params.body = NewDictionary();
		params.body.do = "scplogin";
		params.body.userid = monitorSettings.crmUser || "user"; // the osTicket CRM user name and password should be redefined
		params.body.passwd = monitorSettings.crmPass || "password";
		params.body.submit = "Log In"; 
	}
	return HTTPCall(url,params);
}

To get more info about CommuniGate Contact Center write to support@communigate.ru