Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| inprogress [2019/08/29 16:32] – gerardorourke | inprogress [2019/09/04 22:24] (current) – gerardorourke | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| < | < | ||
| - | < | + | < |
| - | <% | + | |
| - | /* | + | |
| - | Author: Gerard O' | + | Author: Gerard O' |
| - | Date: 29 Auguest | + | Date: 02 September |
| + | Version 1.0 | ||
| + | /* | ||
| - | To Do: Timeouts, Error handling when Site returns incorrect data or no data, put code into functions. | + | /* |
| + | MIT License | ||
| - | /* | + | Copyright (c) 2019 Gerard O' |
| - | /* | + | Permission is hereby granted, free of charge, to any person obtaining a copy |
| - | MIT License | + | of this software and associated documentation files (the " |
| + | in the Software without restriction, | ||
| + | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| + | copies of the Software, and to permit persons to whom the Software is | ||
| + | | ||
| - | Copyright (c) 2019 Gerard O' | + | The above copyright notice and this permission notice shall be included in all |
| + | copies or substantial portions of the Software. | ||
| - | Permission is hereby granted, free of charge, to any person obtaining a copy | + | THE SOFTWARE IS PROVIDED |
| - | of this software and associated documentation files (the "Software"), to deal | + | |
| - | in the Software without restriction, including without limitation the rights | + | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| - | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | + | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| - | copies of the Software, and to permit persons to whom the Software is | + | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| - | furnished to do so, subject to the following conditions: | + | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| + | | ||
| + | */ | ||
| - | The above copyright notice and this permission notice shall be included in all | + | /* |
| - | copies or substantial portions | + | Location |
| + | Example: D: | ||
| + | Example URL: http:// | ||
| + | */ | ||
| - | 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. | ||
| - | */ | ||
| + | try { //Start of Global Try | ||
| - | // CCE & ECE Server Details | + | // ******************************************************************************************** // |
| - | var ccehostname = ' | + | // ******************* You should review and change the BELOW variables |
| - | var ecehostname = ' | + | // ******************************************************************************************** // |
| - | var cceuser = ' | + | |
| - | var ccepass = ' | + | |
| - | // Default Values if unable to read valid values from BusinessHours Name | + | |
| - | var defaultProactiveChatTimer | + | var ccehostname |
| - | var defaultMinAgentCount | + | var ecehostname |
| - | var defaultMaxQueueDepth | + | var cceuser |
| - | var defaultMaxWaitTime | + | var ccepass |
| + | var debuglevel = 1; // 0 = disabled, 1 = minimum, 2 = all - recommend to set to 1 | ||
| + | var SXH_OPTION_2_VALUE = 13056; // SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS -> ' | ||
| + | var resolveTimeout = 3000; // DNS Resolve Timeout (ms) | ||
| + | var connectTimeout = 3000; // Value (ms) is applied to establishing a communication socket with the target server | ||
| + | var sendTimeout = 3000; // The value applies to sending an individual packet of request data (if any) on the communication socket to the target server. (ms) | ||
| + | var receiveTimeout = 3000; // The value applies to receiving a packet of response data from the target server (ms) | ||
| - | // Query String - Retrieve dyanmic | + | |
| - | var myQuerySring | + | var defaultProactiveChatTimer |
| - | var myChatEntryId | + | var defaultMinAgentCount = ' |
| - | var myBusinessHoursId= Request.QueryString(" | + | var defaultMaxQueueDepth |
| + | var defaultMaxWaitTime | ||
| - | // CCE & ECE URLs | + | // ******************************************************************************************** |
| - | var businessHoursUrl = ' | + | // ******************* You should review and change the ABOVE variables |
| - | var liveSessionStatusUrl = 'http://' + ecehostname + '/system/egain/ | + | // ******************************************************************************************** |
| - | var capacityUrl = ' | + | |
| - | var srvXmlHttp | ||
| - | srvXmlHttp = Server.CreateObject(" | ||
| - | srvXmlHttp.setOption(2, | ||
| - | //Retrieve BusinessHours Details from CCE BusinessHours API | + | |
| - | srvXmlHttp.open (" | + | var myProactiveChatTimer |
| - | srvXmlHttp.send(); | + | var myMaxQueueDepth |
| + | var myMaxWaitTime | ||
| + | var myMinAgentCount | ||
| - | var businessHours | + | // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. |
| - | var businessHoursName | + | |
| - | var runTimeStatus | + | var myChatEntryId |
| + | var myBusinessHoursId | ||
| - | //Parse Business Hours Name to retrieve the Proactive Chat Timer, Min Agent Count, Max Queue Depth & Max Wait Timeouts | + | |
| - | var businessHoursNameArray | + | var businessHoursUrl |
| - | var myBusinessHoursName | + | var liveSessionStatusUrl |
| - | var myProactiveChatTimer | + | var capacityUrl |
| - | var myMinAgentCount = businessHoursNameArray[2]; | + | |
| - | var myMaxQueueDepth = businessHoursNameArray[3]; | + | |
| - | var myMaxWaitTime = businessHoursNameArray[4]; | + | |
| - | // Check if Valid Values from BusinessHour - if not - overwrite with the default | + | |
| - | if (isNaN(myProactiveChatTimer)){ | + | var chatStatus |
| - | myProactiveChatTimer | + | var chatStatusReason |
| - | } | + | var chatTimer |
| - | if (isNaN(myMinAgentCount)){ | + | |
| - | myMinAgentCount | + | |
| - | } | + | |
| - | if (isNaN(myMaxQueueDepth)){ | + | |
| - | myMaxQueueDepth | + | |
| - | } | + | |
| - | if (isNaN(myMaxWaitTime)){ | + | |
| - | myMaxWaitTime = defaultMaxWaitTime; | + | |
| - | } | + | |
| - | var chatStatus | + | Response.ContentType |
| - | var chatBusyReason = ' | + | |
| - | var chatTimer = ' | + | |
| - | if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus | + | |
| + | Response.Write(" | ||
| + | | ||
| - | srvXmlHttp.open (" | + | chatstatus |
| - | srvXmlHttp.send(); | + | |
| - | var liveSessionStatus | + | |
| - | var waitTime = liveSessionStatus.selectSingleNode("// | + | |
| - | var queueDepth = liveSessionStatus.selectSingleNode(" | + | |
| - | srvXmlHttp.open (" | + | if (chatstatus == 'open') { |
| - | srvXmlHttp.send(); | + | |
| - | var capacity = srvXmlHttp.responseXML; | + | } |
| - | var count = capacity.selectSingleNode(" | + | |
| + | if (chatstatus == ' | ||
| + | chatstatus = capacityAPI() // ECE Capacity API - returns ' | ||
| + | } | ||
| - | Response.ContentType=" | + | |
| - | Response.Write(" | + | Response.Write(" |
| - | Response.Write(" | + | Response.Write(" |
| - | Response.Write(" | + | |
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | Response.Write(" | ||
| - | %> | ||
| - | </code> | + | // ******************************************************************************************** // |
| + | // ******************************** Functions ************************************************* // | ||
| + | // ******************************************************************************************** // | ||
| + | function businessHoursAPI() { | ||
| + | try { | ||
| + | var srvXmlHttp | ||
| + | srvXmlHttp = Server.CreateObject(" | ||
| + | srvXmlHttp.setOption(2, | ||
| + | srvXmlHttp.setTimeouts(resolveTimeout, | ||
| + | srvXmlHttp.open(" | ||
| + | srvXmlHttp.send(); | ||
| + | var httpstatus = srvXmlHttp.status; | ||
| - | Reference: | + | if (debuglevel > 0) { |
| - | https:// | + | |
| + | } | ||
| - | < | + | if (httpstatus != 200) { |
| - | < | + | |
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| + | return chatStatus; | ||
| + | } | ||
| - | <% | + | chatStatusReason = ''; |
| - | /* | + | var businessHours = srvXmlHttp.responseXML; |
| - | MIT License | + | var businessHoursName = businessHours.selectSingleNode("// |
| + | var runTimeStatus = businessHours.selectSingleNode("// | ||
| + | var configuredStatus = businessHours.selectSingleNode("// | ||
| + | if (configuredStatus.text > 0) { | ||
| + | var reasonText = businessHours.selectSingleNode("// | ||
| + | } | ||
| - | Copyright | + | //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]; | ||
| + | myProactiveChatTimer = businessHoursNameArray[1]; | ||
| + | myMinAgentCount = businessHoursNameArray[2]; | ||
| + | myMaxQueueDepth = businessHoursNameArray[3]; | ||
| + | myMaxWaitTime = businessHoursNameArray[4]; | ||
| - | Permission is hereby granted, free of charge, to any person obtaining a copy | + | myProactiveChatTimer = myProactiveChatTimer*1000; |
| - | of this software and associated documentation files (the " | + | |
| - | in the Software without restriction, | + | |
| - | 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 | + | |
| - | The above copyright notice and this permission notice shall be included in all | + | // Check if Valid Values from BusinessHour - if not - overwrite with the default values. |
| - | copies or substantial portions of the Software. | + | if (isNaN(myProactiveChatTimer)) { |
| + | myProactiveChatTimer = defaultProactiveChatTimer; | ||
| + | } | ||
| + | if (isNaN(myMinAgentCount)) { | ||
| + | myMinAgentCount = defaultMinAgentCount; | ||
| + | } | ||
| + | if (isNaN(myMaxQueueDepth)) { | ||
| + | myMaxQueueDepth = defaultMaxQueueDepth; | ||
| + | } | ||
| + | if (isNaN(myMaxWaitTime)) { | ||
| + | myMaxWaitTime = defaultMaxWaitTime; | ||
| + | } | ||
| - | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | + | if ((runTimeStatus.text == 0 || runTimeStatus.text == 2) && configuredStatus.text > 0) { |
| - | 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. | + | if (runTimeStatus.text == 1 || runTimeStatus.text == 3) { |
| - | var myQuerySring | + | |
| - | var myChatEntryId | + | } |
| - | var myBusinessHoursId= Request.QueryString(" | + | |
| - | //var myChatEntryId = getUrlVars()["chatEntryId"]; | + | if (debuglevel > 1) { |
| - | //Response.Write(" | + | Response.Write("\nconsole.log(' |
| + | if (configuredStatus.text > 0) { | ||
| + | | ||
| + | } | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | } | ||
| + | return chatStatus; | ||
| + | } //Try | ||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| - | var businessHoursUrl = "http:// | + | if (debuglevel > 0) { |
| - | var liveSessionStatusUrl = "http://localhost/ | + | Response.Write("\nconsole.log(' |
| - | var capacityUrl = "http://localhost/ | + | } |
| + | return chatStatus; | ||
| + | } //Catch | ||
| + | | ||
| + | function liveSessionStatusAPI() { | ||
| + | try { | ||
| + | var srvXmlHttp | ||
| + | srvXmlHttp = Server.CreateObject(" | ||
| + | srvXmlHttp.setOption(2, | ||
| + | srvXmlHttp.open(" | ||
| + | srvXmlHttp.send(); | ||
| - | // Default Values if unable to read valid values from BusinessHours Name | + | |
| - | var defaultProactiveChatTimer | + | |
| - | var defaultMinAgentCount = ' | + | |
| - | var defaultMaxQueueDepth = ' | + | |
| - | var defaultMaxWaitTime = ' | + | |
| - | //Retrieve BusinessHours Details from CCE BusinessHours API | + | if (debuglevel > 0) { |
| - | var srvXmlHttp | + | |
| - | srvXmlHttp = Server.CreateObject(" | + | } |
| - | srvXmlHttp.open ("GET", businessHoursUrl, | + | |
| - | srvXmlHttp.send(); | + | |
| - | var businessHours | + | if (httpstatus != 200) { |
| - | var businessHoursName | + | chatStatus |
| - | var runTimeStatus | + | |
| + | myProactiveChatTimer | ||
| + | return chatStatus; | ||
| + | } | ||
| - | var businessHoursNameArray | + | |
| - | var myBusinessHoursName | + | var waitTime = liveSessionStatus.selectSingleNode("// |
| - | var myProactiveChatTimer = businessHoursNameArray[1]; | + | var queueDepth |
| - | 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 | + | |
| - | } | + | myProactiveChatTimer |
| - | if (isNaN(myMinAgentCount)){ | + | } |
| - | myMinAgentCount | + | |
| - | } | + | |
| - | if (isNaN(myMaxQueueDepth)){ | + | |
| - | myMaxQueueDepth = defaultMaxQueueDepth; | + | |
| - | } | + | |
| - | if (isNaN(myMaxWaitTime)){ | + | |
| - | myMaxWaitTime | + | |
| - | } | + | |
| - | var chatStatus = 'closed'; | + | if (parseInt(waitTime.text, |
| - | var chatBusyReason | + | |
| - | var chatTimer | + | |
| + | myProactiveChatTimer | ||
| + | } | ||
| - | if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus | + | |
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | | ||
| - | srvXmlHttp.open (" | + | return chatStatus; |
| - | srvXmlHttp.send(); | + | } //Try |
| - | var liveSessionStatus | + | catch (err) { |
| - | var waitTime | + | chatStatus = ' |
| - | var queueDepth = liveSessionStatus.selectSingleNode("// | + | |
| + | myProactiveChatTimer | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | | ||
| + | } | ||
| + | return chatStatus; | ||
| + | } //Catch | ||
| + | } //Function | ||
| - | srvXmlHttp.open (" | ||
| - | srvXmlHttp.send(); | ||
| - | var capacity = srvXmlHttp.responseXML; | ||
| - | var count = capacity.selectSingleNode("// | ||
| - | Response.ContentType=" | + | function capacityAPI() { |
| - | Response.Write("var chatStatus = '" | + | try { |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write("\nconsole.log(' | + | srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0"); |
| - | Response.Write(" | + | |
| - | Response.Write("\nconsole.log(" | + | |
| - | Response.Write(" | + | |
| + | var httpstatus = srvXmlHttp.status; | ||
| - | Response.Write(" | + | if (debuglevel > 0) { |
| - | Response.Write(" | + | Response.Write(" |
| - | Response.Write(" | + | } |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | %> | + | |
| - | </ | + | if (httpstatus != 200) { |
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | return chatStatus; | ||
| + | } | ||
| + | var capacity = srvXmlHttp.responseXML; | ||
| + | var count = capacity.selectSingleNode("// | ||
| + | if (parseInt(count.text, | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = ' | ||
| + | myProactiveChatTimer = ' | ||
| + | } | ||
| + | if (debuglevel > 1) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | return chatStatus; | ||
| + | } // Try | ||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | chatTimer = ' | ||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | return chatStatus; | ||
| + | |||
| + | } //Catch | ||
| + | } // | ||
| + | } //End of Global Try | ||
| + | |||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | chatTimer = ' | ||
| + | |||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | %> | ||
| + | </ | ||