Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| vendors:cisco:uc:ece:apiexample [2020/11/15 10:38] – [blah] gerardorourke | vendors:cisco:uc:ece:apiexample [2021/04/09 09:15] (current) – gerardorourke | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== ECE chatStatus API ====== | ====== ECE chatStatus API ====== | ||
| - | ===== Legacy | + | ===== Versions ===== |
| - | * Blah | + | * [[vendors: |
| + | * [[vendors: | ||
| + | * [[vendors: | ||
| - | |||
| - | ===== Summary ===== | ||
| - | ** Version 2.0** | ||
| - | \\ | ||
| - | \\ | ||
| - | The chatStatus API can be directly placed onto the ECE Web Server, e.g. D: | ||
| - | * The ECE Web server must have **https** access to the CCE Admin server - so it can access the Business Hours API\\ | ||
| - | * The client browser does not access CCE server directly - only allow access to the CCE API from the DMZ ECE Web server and NOT from the internet\\ | ||
| - | * Code is provided with an MIT license, free of charge to use, copy, modify etc. and without any warranty of any kind. | ||
| - | * The chatStatus returns the current status of the Chat line based on real time data from a specific Business Hours ID (CCE API) and two ECE chat APIs. | ||
| - | * The response is in JSON or JSONP format (JSONP will be returned if the callback variable is set, but this functionality can be disabled). | ||
| - | * If using [[https:// | ||
| - | * If using [[https:// | ||
| - | |||
| - | * [[# | ||
| - | * [[http:// | ||
| - | * [[https:// | ||
| - | |||
| - | Next steps - would be to make this API cacheable - so the backends APIs are already requested every 10 seconds no matter how many clients where using the API. | ||
| - | I will be using [[https:// | ||
| - | |||
| - | ===== Features ===== | ||
| - | * Business Hours - open / close your Web Chat via CCE Business Hours GUI | ||
| - | * Web Chat can dynamically go ' | ||
| - | * Min Agent Availability | ||
| - | * Max Queue Depth | ||
| - | * Max Wait Time | ||
| - | * Simple Proactive Chat - enable / disable & configurable timer | ||
| - | |||
| - | {{: | ||
| - | |||
| - | Business Hour Reasons can also be used to auto change the message for different closed reasons.\\ | ||
| - | |||
| - | {{: | ||
| - | |||
| - | The chatStatus API returns 3 core variables which can be used on your webpage to change the status of your chat. | ||
| - | * chatStatus - this variable is set to open, closed or busy based on real time data from the relevant APIs. | ||
| - | * chatStatusReason (the value of the reason is retrieved via CCE BusinessHours API (or set to "out of service" | ||
| - | * ChatTimer (the time in ms to wait before showing the proactive chat) | ||
| - | |||
| - | Example JSON output | ||
| - | <code Javascript> | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | </ | ||
| - | ===== Steps to enable Demo Web site to work with your ECE Web server ===== | ||
| - | - Download demo website code - https:// | ||
| - | - Edit the index.html and jsonp-example.html files by doing a **find and replace** of **" | ||
| - | - Download [[# | ||
| - | - Host on your ECE Web server: D: | ||
| - | - Note - if your locate the file in a different folder on the ECE Webserver - update the relevant chatStatus.asp URLs in the index.html / ece-undocked.html files | ||
| - | - Update the following variables in the chatStatus.asp file with your relevant details (see chatStatus.asp for more info) | ||
| - | * ccehostname | ||
| - | * ecehostname | ||
| - | * cceuser | ||
| - | * ccepass | ||
| - | - Configuring [[# | ||
| - | |||
| - | Sample Chat Demo Located here: http:// | ||
| - | |||
| - | |||
| - | ===== chatStatus.asp ===== | ||
| - | |||
| - | Place this file on your ECE Web server - so it is accessible from the client Web Browser.\\ | ||
| - | Example location: D: | ||
| - | Example Web URL: http:// | ||
| - | |||
| - | <file asp chatStatus.asp> | ||
| - | < | ||
| - | |||
| - | <% | ||
| - | |||
| - | /* | ||
| - | Author: Gerry O' | ||
| - | Date: 22 September 2019 | ||
| - | Version 2.0 | ||
| - | /* | ||
| - | |||
| - | /* | ||
| - | MIT License | ||
| - | |||
| - | Copyright (c) 2019 Gerard O' | ||
| - | |||
| - | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| - | 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 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. | ||
| - | */ | ||
| - | |||
| - | /* | ||
| - | Example Location of File on ECE Web Server: | ||
| - | D: | ||
| - | |||
| - | Example JSON format URL: | ||
| - | http:// | ||
| - | |||
| - | Example JSONP format URL: | ||
| - | http:// | ||
| - | */ | ||
| - | |||
| - | /* | ||
| - | --- Overview --- | ||
| - | |||
| - | The relevant businessHourId and chatEntryId (case sensative) must be passed into this script otherwise a chatStatus of ' | ||
| - | The response is in JSON format, unless a query variable ' | ||
| - | |||
| - | This key variables chatStatus API that are returned via JSON format are:. | ||
| - | chatStatus | ||
| - | chatStatusReason | ||
| - | myProactiveChatTimer | ||
| - | |||
| - | --- chatStatus --- | ||
| - | This Variable chatStatus should return one of 3 possible values | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | | ||
| - | --- chatStatusReason --- | ||
| - | This Variable should return the reasonText from the BusinessHours API. In the Web Demo, the reasonText of " | ||
| - | This enabled a differnet closed message if the day was a holiday or was forced closed and Reason set to ' | ||
| - | |||
| - | --- myProactiveChatTimer --- | ||
| - | This is the timer for a Proactive Chat in Milliseconds. The time in SECONDS is set as part of the Business Hour Name | ||
| - | e.g. a Business Hours Name of " | ||
| - | A = proactive timer set in seconds, e.g. for 10 seconds before a proactive chat is given set to ' | ||
| - | B = Minimum Number of Chat Agents required - before giving back chatStatus of ' | ||
| - | C = Max Queue Depth - e.g. set to 5 to give back a busy if there are 5 or more chats in the current chat queue | ||
| - | D = Max Expected Wait Time in seconds, e.g. set to ' | ||
| - | |||
| - | Example Business Hours Name: " | ||
| - | |||
| - | Example JSON Output: | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | |||
| - | For more info check out: http:// | ||
| - | For chat Demo Check out: http:// | ||
| - | |||
| - | For Sample HTML + JavaScript Code using this chatStatus API to create a dyanmically updating webpage: | ||
| - | https:// | ||
| - | */ | ||
| - | |||
| - | |||
| - | try { //start of Global Try | ||
| - | |||
| - | // ******************************************************************************************** // | ||
| - | // *************************** Review and change the BELOW variables | ||
| - | // ******************************************************************************************** // | ||
| - | |||
| - | // Variables CCE & ECE Server Details | ||
| - | var ccehostname = ' | ||
| - | var ecehostname = ' | ||
| - | var cceuser = ' | ||
| - | var ccepass = ' | ||
| - | |||
| - | // HTTPS Connection Timemout and TLS setttings | ||
| - | 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) | ||
| - | |||
| - | // Default Values if unable to read valid values from BusinessHours Name | ||
| - | var defaultProactiveChatTimer = ' | ||
| - | var defaultMinAgentCount = ' | ||
| - | var defaultMaxQueueDepth = ' | ||
| - | var defaultMaxWaitTime = ' | ||
| - | var debuglevel = 1; // 0 = disabled, 1 = minimum (use on client to output JSON to Console, 2 = basic debugging, 3 = all. Set to 0 in production unless you have an issue to troubleshoot the script. | ||
| - | var JSONP_allow = true; | ||
| - | |||
| - | // ******************************************************************************************** // | ||
| - | // **************************** Review and change the ABOVE variables | ||
| - | // ******************************************************************************************** // | ||
| - | |||
| - | // Initial JS variable values | ||
| - | var chatStatus = ' | ||
| - | var chatStatusReason = 'out of service'; | ||
| - | var errorcode = ' | ||
| - | var errorstring = ''; | ||
| - | |||
| - | // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. | ||
| - | var myQuerySring = Request.QueryString; | ||
| - | var myChatEntryId = Request.QueryString(" | ||
| - | var myBusinessHoursId = Request.QueryString(" | ||
| - | var myCallback = Request.QueryString(" | ||
| - | var responseFormat = ' | ||
| - | var outputfilestarted = false; | ||
| - | |||
| - | // CCE & ECE URLs | ||
| - | var businessHoursUrl = ' | ||
| - | var liveSessionStatusUrl = ' | ||
| - | var capacityUrl = ' | ||
| - | |||
| - | // Declare Global Variables used in both businessHours and ECE APIs | ||
| - | var myProactiveChatTimer = ' | ||
| - | var myMaxQueueDepth | ||
| - | var myMaxWaitTime | ||
| - | var myMinAgentCount | ||
| - | |||
| - | if (isNaN(myChatEntryId)) { | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | } | ||
| - | |||
| - | if (isNaN(myBusinessHoursId)) { | ||
| - | errorcode = ' | ||
| - | errorstring = errorstring + ' | ||
| - | } | ||
| - | |||
| - | if ((Request.QueryString(" | ||
| - | if (/ | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | } | ||
| - | else{ | ||
| - | responseFormat = ' | ||
| - | } | ||
| - | } | ||
| - | |||
| - | // ***** Start of Output File ***** | ||
| - | |||
| - | if (responseFormat == ' | ||
| - | Response.ContentType = " | ||
| - | Response.Write(myCallback + ' | ||
| - | } else { | ||
| - | Response.ContentType = " | ||
| - | } | ||
| - | Response.Write(' | ||
| - | outputfilestarted = true; | ||
| - | |||
| - | if (errorcode == ' | ||
| - | chatStatus = businessHoursAPI() // BusinessHours API - returns ' | ||
| - | } | ||
| - | |||
| - | if ((chatStatus == ' | ||
| - | chatStatus = liveSessionStatusAPI() // ECE liveSessionStatus API - returns ' | ||
| - | } | ||
| - | |||
| - | if ((chatStatus == ' | ||
| - | chatStatus = capacityAPI() // ECE Capacity API - returns ' | ||
| - | } | ||
| - | |||
| - | if (debuglevel > 1) { | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | |||
| - | if (responseFormat == ' | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | // ******************************************************************************************** // | ||
| - | // ******************************** Functions ************************************************* // | ||
| - | // ******************************************************************************************** // | ||
| - | |||
| - | function businessHoursAPI() { | ||
| - | try { | ||
| - | var srvXmlHttp | ||
| - | srvXmlHttp = Server.CreateObject(" | ||
| - | srvXmlHttp.setOption(2, | ||
| - | srvXmlHttp.setTimeouts(resolveTimeout, | ||
| - | srvXmlHttp.open(" | ||
| - | srvXmlHttp.send(); | ||
| - | |||
| - | var httpstatus = srvXmlHttp.status; | ||
| - | |||
| - | if (debuglevel > 1) { | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | if (httpstatus != 200) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | myProactiveChatTimer = ' | ||
| - | errorcode = httpstatus; | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } | ||
| - | |||
| - | var businessHours = srvXmlHttp.responseXML; | ||
| - | var businessHoursName = businessHours.selectSingleNode("// | ||
| - | var runTimeStatus = businessHours.selectSingleNode("// | ||
| - | var runTimeStatusReason = businessHours.selectSingleNode("// | ||
| - | chatStatusReason = runTimeStatusReason.text; | ||
| - | |||
| - | //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]; | ||
| - | |||
| - | myProactiveChatTimer = myProactiveChatTimer * 1000; //Converts ChatTimer from seconds to milliseconds | ||
| - | |||
| - | // Check if Valid Values from BusinessHour - if not - overwrite with the default values. | ||
| - | if (isNaN(myProactiveChatTimer)) { | ||
| - | myProactiveChatTimer = defaultProactiveChatTimer * 1000; //note - converts to milliseconds | ||
| - | } | ||
| - | if (isNaN(myMinAgentCount)) { | ||
| - | myMinAgentCount = defaultMinAgentCount; | ||
| - | } | ||
| - | if (isNaN(myMaxQueueDepth)) { | ||
| - | myMaxQueueDepth = defaultMaxQueueDepth; | ||
| - | } | ||
| - | if (isNaN(myMaxWaitTime)) { | ||
| - | myMaxWaitTime = defaultMaxWaitTime; | ||
| - | } | ||
| - | |||
| - | if (runTimeStatus.text == 1 || runTimeStatus.text == 3) { | ||
| - | chatStatus = ' | ||
| - | } else { | ||
| - | chatStatus = ' | ||
| - | myProactiveChatTimer = ' | ||
| - | } | ||
| - | |||
| - | if (debuglevel > 2) { | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | return chatStatus; | ||
| - | } //Try | ||
| - | catch (err) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | myProactiveChatTimer = ' | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } //end of catch | ||
| - | } //end of function | ||
| - | |||
| - | |||
| - | function liveSessionStatusAPI() { | ||
| - | try { | ||
| - | var srvXmlHttp | ||
| - | srvXmlHttp = Server.CreateObject(" | ||
| - | srvXmlHttp.setOption(2, | ||
| - | srvXmlHttp.open(" | ||
| - | srvXmlHttp.send(); | ||
| - | |||
| - | var httpstatus = srvXmlHttp.status; | ||
| - | |||
| - | if (debuglevel > 1) { | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | if (httpstatus != 200) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | myProactiveChatTimer = ' | ||
| - | errorcode = httpstatus; | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } | ||
| - | |||
| - | |||
| - | var liveSessionStatus = srvXmlHttp.responseXML; | ||
| - | var waitTime = liveSessionStatus.selectSingleNode("// | ||
| - | var queueDepth = liveSessionStatus.selectSingleNode("// | ||
| - | |||
| - | if (parseInt(queueDepth.text, | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = ' | ||
| - | myProactiveChatTimer = ' | ||
| - | } | ||
| - | |||
| - | if (parseInt(waitTime.text, | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = ' | ||
| - | myProactiveChatTimer = ' | ||
| - | } | ||
| - | |||
| - | if (debuglevel > 2) { | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | } | ||
| - | return chatStatus; | ||
| - | } //end of try | ||
| - | catch (err) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | myProactiveChatTimer = ' | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } //end of catch | ||
| - | } //end of function | ||
| - | |||
| - | |||
| - | |||
| - | function capacityAPI() { | ||
| - | try { | ||
| - | |||
| - | srvXmlHttp = Server.CreateObject(" | ||
| - | srvXmlHttp.setOption(2, | ||
| - | srvXmlHttp.open(" | ||
| - | srvXmlHttp.send(); | ||
| - | |||
| - | var httpstatus = srvXmlHttp.status; | ||
| - | |||
| - | if (debuglevel > 1) { | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | if (httpstatus != 200) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | myProactiveChatTimer = ' | ||
| - | errorcode = httpstatus; | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } | ||
| - | |||
| - | var capacity = srvXmlHttp.responseXML; | ||
| - | var count = capacity.selectSingleNode("// | ||
| - | |||
| - | if (parseInt(count.text, | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = ' | ||
| - | myProactiveChatTimer = ' | ||
| - | } | ||
| - | |||
| - | if (debuglevel > 2) { | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | return chatStatus; | ||
| - | } // Try | ||
| - | catch (err) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | chatTimer = ' | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | return chatStatus; | ||
| - | } //Catch | ||
| - | } // | ||
| - | |||
| - | |||
| - | } //End of Global Try | ||
| - | |||
| - | catch (err) { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | chatTimer = ' | ||
| - | errorcode = ' | ||
| - | errorstring = ' | ||
| - | |||
| - | if ((outputfilestarted == false) || (typeof outputfilestarted == ' | ||
| - | if (responseFormat == ' | ||
| - | Response.ContentType = " | ||
| - | Response.Write(myCallback + ' | ||
| - | } else { | ||
| - | Response.ContentType = " | ||
| - | } | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | Response.Write(' | ||
| - | } | ||
| - | |||
| - | %> | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Example JavaScript using the chatStatus API on a webpage ===== | ||
| - | |||
| - | Example code you would add to the **bottom** of your HTML page to call the chatStatus API\\ | ||
| - | Update the relevant host names of your ECE Web server switch and your businessHour and ECE chat Entry IDs.\\ | ||
| - | Note: along with this code - the standard ECE code snippets also need to be added (Check out the sample website code on [[https:// | ||
| - | |||
| - | <code Javascript> | ||
| - | <!-- JavaScript to Show or Hide the open / closed / busy Chat options based on ' | ||
| - | <script type=" | ||
| - | |||
| - | // Initiate Variables | ||
| - | var chatStatus = ' | ||
| - | var chatStatusReason = 'out of service'; | ||
| - | var chatTimer = ' | ||
| - | var chatProactiveAttempts = ' | ||
| - | var chatStatusRefreshTimer = ' | ||
| - | var chatProactiveRetryAttempts = ' | ||
| - | var chatStatusUrl = " | ||
| - | var mybusinessHourId = ' | ||
| - | var mychatEntryId = ' | ||
| - | |||
| - | getChatStatus(); | ||
| - | |||
| - | function getChatStatus() { //Note - the JSON Response gets auto parsed by jQuery. | ||
| - | $.ajax({ | ||
| - | url: chatStatusUrl, | ||
| - | data: {businessHoursId: | ||
| - | dataType: | ||
| - | success: function(chatStatusAPI) { | ||
| - | chatStatus = chatStatusAPI.chatStatus; | ||
| - | chatStatusReason = chatStatusAPI.chatStatusReason; | ||
| - | chatTimer = chatStatusAPI.chatTimer; | ||
| - | if (chatStatusAPI.debugLevel > 0) { | ||
| - | console.log(" | ||
| - | console.log(chatStatusAPI); | ||
| - | console.log(" | ||
| - | } | ||
| - | setChatStatus(); | ||
| - | } | ||
| - | }) | ||
| - | .fail(function() { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | chatTimer = ' | ||
| - | console.log(" | ||
| - | setChatStatus(); | ||
| - | }) | ||
| - | |||
| - | }; | ||
| - | |||
| - | function setChatStatus() { | ||
| - | |||
| - | if (chatStatus == ' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | |||
| - | if (chatStatusReason == ' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | } | ||
| - | if (chatStatusReason == ' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | } | ||
| - | if (chatStatusReason == 'out of service' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | } | ||
| - | } | ||
| - | |||
| - | if (chatStatus == ' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | } | ||
| - | |||
| - | if (chatStatus == ' | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | $('# | ||
| - | |||
| - | // | ||
| - | if (chatProactiveRetryAttempts > chatProactiveAttempts){ | ||
| - | setTimeout(function() { | ||
| - | if ((chatTimer != 0) && (chatStatus == ' | ||
| - | chatProactiveAttempts++ | ||
| - | $('# | ||
| - | } | ||
| - | }, chatTimer); | ||
| - | } | ||
| - | } | ||
| - | if (chatStatusReason != 'out of service' | ||
| - | setTimeout(getChatStatus, | ||
| - | } | ||
| - | } | ||
| - | |||
| - | function disableProactiveChat() { | ||
| - | window.chatTimer = 0; | ||
| - | console.log(' | ||
| - | } | ||
| - | |||
| - | |||
| - | </ | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== JSONP JavaScript Extract ===== | ||
| - | |||
| - | The JSONP version of the JavaScript code is very similar to above JSON version, except ajax is configured with dataType **jsonp** format and the callback variable " | ||
| - | |||
| - | The advantage of JSONP is that CORS is not a requirement due to how browsers handle JSONP. Check out this [[https:// | ||
| - | |||
| - | <code javascript> | ||
| - | function getChatStatus() { //Note - the JSON Response gets auto parsed by jQuery. | ||
| - | $.ajax({ | ||
| - | url: chatStatusUrl, | ||
| - | data: {businessHoursId: | ||
| - | dataType: ' | ||
| - | jsonp: ' | ||
| - | jsonpCallback: | ||
| - | success: function(data) { | ||
| - | // | ||
| - | } | ||
| - | }) | ||
| - | .fail(function() { | ||
| - | chatStatus = ' | ||
| - | chatStatusReason = 'out of service'; | ||
| - | chatTimer = ' | ||
| - | console.log(" | ||
| - | setChatStatus(); | ||
| - | }) | ||
| - | |||
| - | }; | ||
| - | |||
| - | |||
| - | function chatStatusParse(chatStatusAPI){ | ||
| - | chatStatus = chatStatusAPI.chatStatus; | ||
| - | chatStatusReason = chatStatusAPI.chatStatusReason; | ||
| - | chatTimer = chatStatusAPI.chatTimer; | ||
| - | if (chatStatusAPI.debugLevel > 0) { | ||
| - | console.log(" | ||
| - | console.log(chatStatusAPI); | ||
| - | console.log(" | ||
| - | } | ||
| - | setChatStatus(); | ||
| - | } | ||
| - | </ | ||
| - | ===== HTML for Proactive Chat ===== | ||
| - | Note - uses Bootstrap CSS **Modal** for Popup - [[https:// | ||
| - | |||
| - | <code html> | ||
| - | <!-- Modal --> | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <h5 class=" | ||
| - | <button type=" | ||
| - | <span aria-hidden=" | ||
| - | </ | ||
| - | </ | ||
| - | <div class=" | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | <div class=" | ||
| - | <button type=" | ||
| - | <button type=" | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ===== ECE & CCE APIs used to achieve this functionality ===== | ||
| - | ==== ECE - liveSessionStatus - Display chat option based on queue depth and wait time ==== | ||
| - | **http:// | ||
| - | |||
| - | <code xml> | ||
| - | <?xml version=" | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ==== ECE - Agent Capacity ==== | ||
| - | **http:// | ||
| - | |||
| - | <code xml> | ||
| - | <?xml version=" | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ==== CCE - Business Hours ==== | ||
| - | |||
| - | **https:// | ||
| - | |||
| - | <code xml> | ||
| - | <?xml version=" | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ===== CORS IIS Config ===== | ||
| - | This IIS URL Rewrite example configuration enables CORS, i.e. Cross-Origin Resource Sharing for the **purplepi.ie** domain. | ||
| - | This rule matches against the **origin** header and if it is ends with **purplepi.ie**, | ||
| - | |||
| - | For Example - a http request with the following header: | ||
| - | < | ||
| - | Origin: http:// | ||
| - | </ | ||
| - | |||
| - | Since this matches it will reply back with header set of | ||
| - | < | ||
| - | Access-Control-Allow-Origin: | ||
| - | </ | ||
| - | |||
| - | ==== URL Rewrite sample Config for purplepi.ie domain and any subdomain ==== | ||
| - | |||
| - | Update the C: | ||
| - | |||
| - | <code xml> | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | <rule name=" | ||
| - | < | ||
| - | < | ||
| - | <add input=" | ||
| - | </ | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ===== Disabling Chat Banner ===== | ||
| - | |||
| - | [[https:// | ||
| - | |||
| - | Locate **egainDockChat.UseCustomButton** and **egainDockChatIsChatLaunched** and set the values | ||
| - | to true and if you wish to allow the docked chat entry point to be initiated through a custom button or offer | ||
| - | banner other than “Docked Chat”. | ||