This is an old revision of the document!
In progress
<%@language=JScript%> <% /* Author: Gerard O'Rourke Date: 29 Auguest 2019 To Do: Timeouts, Error handling when Site returns incorrect data or no data, put code into functions. /* /* MIT License Copyright (c) 2019 Gerard O'Rourke - purplepi.ie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // CCE & ECE Server Details var ccehostname = 'ucce-hds-a.lab2.purplepi.ie'; var ecehostname = 'ucce-ece-db-12.lab2.purplepi.ie'; var cceuser = '[email protected]'; var ccepass = 'myPa$$w0rd!'; // Default Values if unable to read valid values from BusinessHours Name var defaultProactiveChatTimer = '0'; var defaultMinAgentCount = '0'; var defaultMaxQueueDepth = '10'; var defaultMaxWaitTime = '120'; // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. var myQuerySring = Request.QueryString; var myChatEntryId = Request.QueryString("chatEntryId"); var myBusinessHoursId= Request.QueryString("businessHoursId"); // CCE & ECE URLs var businessHoursUrl = 'https://' + ccehostname + '/unifiedconfig/config/businesshour/' + myBusinessHoursId; var liveSessionStatusUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/liveSessionStatus/' + myChatEntryId; var capacityUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/capacity/' + myChatEntryId; var srvXmlHttp srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0"); srvXmlHttp.setOption(2,13056); //Ignore SSL Certs //Retrieve BusinessHours Details from CCE BusinessHours API srvXmlHttp.open ("GET", businessHoursUrl, false, cceuser, ccepass); srvXmlHttp.send(); var businessHours = srvXmlHttp.responseXML; var businessHoursName = businessHours.selectSingleNode("//businessHour/name"); var runTimeStatus = businessHours.selectSingleNode("//businessHour/runTimeStatus"); //Parse Business Hours Name to retrieve the Proactive Chat Timer, Min Agent Count, Max Queue Depth & Max Wait Timeouts var businessHoursNameArray = businessHoursName.text.split("_"); var myBusinessHoursName = businessHoursNameArray[0]; var myProactiveChatTimer = businessHoursNameArray[1]; var myMinAgentCount = businessHoursNameArray[2]; var myMaxQueueDepth = businessHoursNameArray[3]; var myMaxWaitTime = businessHoursNameArray[4]; // Check if Valid Values from BusinessHour - if not - overwrite with the default values. if (isNaN(myProactiveChatTimer)){ myProactiveChatTimer = defaultProactiveChatTimer; } if (isNaN(myMinAgentCount)){ myMinAgentCount = defaultMinAgentCount; } if (isNaN(myMaxQueueDepth)){ myMaxQueueDepth = defaultMaxQueueDepth; } if (isNaN(myMaxWaitTime)){ myMaxWaitTime = defaultMaxWaitTime; } var chatStatus = 'closed'; var chatBusyReason = 'unknown'; var chatTimer = '0'; if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus = 'open';} srvXmlHttp.open ("GET", liveSessionStatusUrl, false); srvXmlHttp.send(); var liveSessionStatus = srvXmlHttp.responseXML; var waitTime = liveSessionStatus.selectSingleNode("//ns2:waitTime"); var queueDepth = liveSessionStatus.selectSingleNode("//ns2:queueDepth"); srvXmlHttp.open ("GET", capacityUrl, false); srvXmlHttp.send(); var capacity = srvXmlHttp.responseXML; var count = capacity.selectSingleNode("//ns2:count"); Response.ContentType="application/javascript"; Response.Write("var chatStatus = '" + chatStatus + "';\n"); Response.Write("var chatBusyReason = '" + chatBusyReason + "';\n"); Response.Write("var chatTimer = '" + chatTimer + "';\n"); Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - Start ------')"); Response.Write("\nconsole.log('QueryString: " + Request.QueryString + "');"); Response.Write("\nconsole.log('businessHoursId: " + myBusinessHoursId + "');"); Response.Write("\nconsole.log('ChatEntryId: " + myChatEntryId + "');"); Response.Write("\nconsole.log('Full BusinessHoursName: " + businessHoursName.text + "')"); Response.Write("\nconsole.log('myBusinessHoursName: " + myBusinessHoursName + "')"); Response.Write("\nconsole.log('myProactiveChatTimer: " + myProactiveChatTimer + "')"); Response.Write("\nconsole.log('myMinAgentCount: " + myMinAgentCount + "')"); Response.Write("\nconsole.log('myMaxQueueDepth: " + myMaxQueueDepth + "')"); Response.Write("\nconsole.log('myMaxWaitTime: " + myMaxWaitTime + "')"); Response.Write("\nconsole.log('runTimeStatus: " + runTimeStatus.text + "')"); Response.Write("\nconsole.log('waitTime: " + waitTime.text + "')"); Response.Write("\nconsole.log('queueDepth: " + queueDepth.text + "')"); Response.Write("\nconsole.log('agentCount: " + count.text + "')"); Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - End ------')"); %>
Reference: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms763809(v%3Dvs.85)
<%@language=JScript%>
<%
/*
MIT License
Copyright (c) 2019 Gerard O'Rourke - purplepi.ie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs.
var myQuerySring = Request.QueryString;
var myChatEntryId = Request.QueryString("chatEntryId");
var myBusinessHoursId= Request.QueryString("businessHoursId");
//var myChatEntryId = getUrlVars()["chatEntryId"];
//Response.Write("\nconsole.log('myChatEntryId: " + myChatEntryId + "')");
var businessHoursUrl = "http://localhost/xmlfiles/businessHours.xml"
var liveSessionStatusUrl = "http://localhost/xmlfiles/liveSessionStatus.xml"
var capacityUrl = "http://localhost/xmlfiles/capacity.xml"
// Default Values if unable to read valid values from BusinessHours Name
var defaultProactiveChatTimer = '0';
var defaultMinAgentCount = '0';
var defaultMaxQueueDepth = '10';
var defaultMaxWaitTime = '120';
//Retrieve BusinessHours Details from CCE BusinessHours API
var srvXmlHttp
srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0");
srvXmlHttp.open ("GET", businessHoursUrl, false);
srvXmlHttp.send();
var businessHours = srvXmlHttp.responseXML;
var businessHoursName = businessHours.selectSingleNode("//department/name");
var runTimeStatus = businessHours.selectSingleNode("//runTimeStatus");
var businessHoursNameArray = businessHoursName.text.split("_");
var myBusinessHoursName = businessHoursNameArray[0];
var myProactiveChatTimer = businessHoursNameArray[1];
var myMinAgentCount = businessHoursNameArray[2];
var myMaxQueueDepth = businessHoursNameArray[3];
var myMaxWaitTime = businessHoursNameArray[4];
// Check if Valid Values from BusinessHour - if not - overwrite with the default values.
if (isNaN(myProactiveChatTimer)){
myProactiveChatTimer = defaultProactiveChatTimer;
}
if (isNaN(myMinAgentCount)){
myMinAgentCount = defaultMinAgentCount;
}
if (isNaN(myMaxQueueDepth)){
myMaxQueueDepth = defaultMaxQueueDepth;
}
if (isNaN(myMaxWaitTime)){
myMaxWaitTime = defaultMaxWaitTime;
}
var chatStatus = 'closed';
var chatBusyReason = 'unknown';
var chatTimer = '0';
if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus = 'open';}
srvXmlHttp.open ("GET", liveSessionStatusUrl, false);
srvXmlHttp.send();
var liveSessionStatus = srvXmlHttp.responseXML;
var waitTime = liveSessionStatus.selectSingleNode("//ns2:waitTime");
var queueDepth = liveSessionStatus.selectSingleNode("//ns2:queueDepth");
srvXmlHttp.open ("GET", capacityUrl, false);
srvXmlHttp.send();
var capacity = srvXmlHttp.responseXML;
var count = capacity.selectSingleNode("//ns2:count");
Response.ContentType="application/javascript";
Response.Write("var chatStatus = '" + chatStatus + "';\n");
Response.Write("var chatBusyReason = '" + chatBusyReason + "';\n");
Response.Write("var chatTimer = '" + chatTimer + "';\n");
Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - Start ------')");
Response.Write("\nconsole.log(" + Request.QueryString + ");");
Response.Write("\nconsole.log(" + myChatEntryId + ");");
Response.Write("\nconsole.log(" + myBusinessHoursId + ");");
Response.Write("\nconsole.log('Full BusinessHoursName: " + businessHoursName.text + "')");
Response.Write("\nconsole.log('myBusinessHoursName: " + myBusinessHoursName + "')");
Response.Write("\nconsole.log('myProactiveChatTimer: " + myProactiveChatTimer + "')");
Response.Write("\nconsole.log('myMinAgentCount: " + myMinAgentCount + "')");
Response.Write("\nconsole.log('myMaxQueueDepth: " + myMaxQueueDepth + "')");
Response.Write("\nconsole.log('myMaxWaitTime: " + myMaxWaitTime + "')");
Response.Write("\nconsole.log('runTimeStatus: " + runTimeStatus.text + "')");
Response.Write("\nconsole.log('waitTime: " + waitTime.text + "')");
Response.Write("\nconsole.log('queueDepth: " + queueDepth.text + "')");
Response.Write("\nconsole.log('agentCount: " + count.text + "')");
Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - End ------')");
%>