Mitel Chat
This document describes how to integrate the chat service of Mitel MiContact with a Virtual Assistant (VA) using Teneo Web Chat (TWC) and Teneo Engine. With this integration, TWC serves as a frontend to both Teneo Engine and the chat service of Mitel MiContact so the user can start a conversation with the Virtual Assistant and get connected to a Live Chat agent later if needed. This document covers version 9.4 of Mitel Live Chat as specified in this document, which includes file upload among its functionalities.
Prerequisites
These instructions assume your Teneo solution is published and that you know the Engine URL.
Setup instructions
Frontend
- In the file twcMitelExtension.js, locate the definition/assignment of the variable
nMaxWaitedMillis
and make sure it is assigned a value in milliseconds which is 30-60 seconds less than the timeout of your Teneo Engine (which is normally 10 minutes), as in this example:
javascript
1const nMaxWaitedMillis = 540000;
2
- Deploy TWC as per these instructions.
- Add (the content of) the extensions file twcMitelExtension.js somewhere between the file "teneo-web-chat.js" (the TWC core code) and the TWC initialization code, i.e., after the link to "teneo-web-chat.js" and before the code block where
window.TeneoWebChat.initialize(...)
is called (both are explicitly mentioned in the TWC deployment instructions):
html
1<script src="/path/to/teneo-web-chat.js"></script>
2...
3<script src="/path/to/twcMitelExtension.js"></script>
4...
5<script>
6// The TWC initialization code
7...
8window.TeneoWebChat.initialize(...);
9...
10</script>
11
Teneo Engine
Initialization
Implement the following global configurations:
- Upload submitAdd.jsp into the / folder of your solution (not into /views where JSPs are uploaded by default).
- Add the content of MitelChatAux.groovy to the 'Solution loaded' script.
- Add the following global session variables with their corresponding initial values (you might want to add and initialize them in the variable definition section of your solution):
groovy
1// Customer chat configuration (set your own property values):
2mMitelChatConfig = [
3 "sChatBaseUrl": "https://your-mitel-chat-service.com/ChatService/",
4 "sCustomerID": null,
5 "sCustomerName": null,
6 "sEmailAddress": null,
7 "sPhoneNumber": null,
8 "nTenantID": 0,
9 "nServiceGroupID": 0,
10 "sServiceGroupName": "",
11 "sPrivateData": null,
12 "sSessionID": null
13];
14
15// Estimated time in seconds to wait for a live chat agent (-1 if it cannot be estimated):
16nEstimatedWaitTime = -1;
17
18// The stringified JSON object to be returned in the output parameter "mitelLiveChatData"
19// to start the live chat handover in the TWC frontend:
20sMitelLiveChatData = "";
21
22// Possible error:
23mitelError = null;
24
Your Mitel chat provider should tell you what values you should use for all the properties of mMitelChatConfig
except sSessionID
which will be assigned dynamically. In this Mitel Chat Document, you can find what these properties stand for by looking for their counterparts without the Hungarian-style notation prefixes s and n.
Checking the estimated waiting time for a Live Chat agent to pick up the chat
The estimated waiting time for a Live Chat agent to pick up the chat can be checked with the following groovy script:
groovy
1nEstimatedWaitTime = -1;
2mitelError = null;
3String sUrl = mMitelChatConfig.sChatBaseUrl;
4if (sUrl) sUrl += 'GetQueueInfo'
5else throw new RuntimeException('MitelChatAux, mMitelChatConfig has no sChatBaseUrl');
6Map requestParam = new HashMap();
7if (mMitelChatConfig.nTenantID != null) requestParam['TenantID'] = mMitelChatConfig.nTenantID;
8if (mMitelChatConfig.nServiceGroupID != null) requestParam['ServiceGroupID'] = mMitelChatConfig.nServiceGroupID;
9def dto = [request: requestParam];
10String sBody = new groovy.json.JsonBuilder(dto).toString();
11requestParam = dto = null;
12try {
13 def x = MitelChatAux.fetchJsonFromUrl(sUrl, sBody).d;
14 nEstimatedWaitTime = x.EstimatedWaitTime;
15} catch(Exception ex) {
16 mitelError = ex;
17}
18
As a result of the execution of this script the variable nEstimatedWaitTime
will be assigned the approximate time in seconds the user is expected to wait. It will be -1 if it cannot be estimated for whatever reason. If the check fails with an error, the variable mitelError
will get a non-null value. If it succeeds, mitelError
will be assigned null.
Transferring the user to the Live Chat
In order to transfer the user to the Live Chat, your Teneo Engine should simultaneously return to the TWC the output parameters described below.
Obligatory output parameters
mitelLiveChatData
: The value of this output parameter is a stringified JSON object containing all the data needed by the chat service to start the Live Chat. This value is obtained with the following code assigning the value in question to the global session variablesMitelLiveChatData
:
groovy
1sMitelLiveChatData = '';
2mitelError = null;
3String sUrl = mMitelChatConfig.sChatBaseUrl;
4if (sUrl) sUrl += 'RequestChat'
5else {
6 mitelError = new RuntimeException('mMitelChatConfig has no sChatBaseUrl');
7 throw mitelError;
8}
9Map m = new HashMap();
10if (mMitelChatConfig.sSessionID != null) m['SessionID'] = mMitelChatConfig.sSessionID;
11if (mMitelChatConfig.sCustomerID != null) m['CustomerID'] = mMitelChatConfig.sCustomerID;
12if (mMitelChatConfig.sCustomerName != null) m['CustomerName'] = mMitelChatConfig.sCustomerName;
13if (mMitelChatConfig.sEmailAddress != null) m['EmailAddress'] = mMitelChatConfig.sEmailAddress;
14if (mMitelChatConfig.sPhoneNumber != null) m['PhoneNumber'] = mMitelChatConfig.sPhoneNumber;
15if (mMitelChatConfig.nTenantID != null) m['TenantID'] = mMitelChatConfig.nTenantID;
16if (mMitelChatConfig.nServiceGroupID != null) m['ServiceGroupID'] = mMitelChatConfig.nServiceGroupID;
17if (mMitelChatConfig.sServiceGroupName != null) m['ServiceGroupName'] = mMitelChatConfig.sServiceGroupName;
18if (mMitelChatConfig.sPrivateData != null) m['PrivateData'] = mMitelChatConfig.sPrivateData;
19
20String sBody = new groovy.json.JsonBuilder([request: m]).toString();
21try {
22 def mitelLiveChatDataContainer = MitelChatAux.fetchJsonFromUrl(sUrl, sBody);
23 m.putAll(mitelLiveChatDataContainer.d);
24 m.sChatBaseUrl = mMitelChatConfig.sChatBaseUrl;
25 // Set to true if you want to see debug info in the browser console:
26 m.bDebug = false;
27 // Create a stringified JSON-formatted config (containing the chat session ID)
28 // to return to the FE in the output parameter "mitelLiveChatData". This object is
29 // used to create an instance of the Mitel chat handler class:
30 sMitelLiveChatData = new groovy.json.JsonBuilder(m).toString();
31} catch (err) {
32 mitelError = ex;
33}
34
If this script succeeds, sMitelLiveChatData
will be assigned a non-empty string. You should make sure it is then returned via the output parameter mitelLiveChatData
. It will be the indication for the TWC to start the handover process. If this script fails, sMitelLiveChatData
will become an empty string and mitelError
will become a non-null value (it will be null if the script succeeds).
Optional output parameters
askCloseLiveChatWithFeedback
: the confirmation dialog that appears if the user clicks the close button of the frontend in the Live Chat mode and the backend session has not expired yet. The goal of this dialog is to prevent the user from accidentally closing the Live Chat AND to invite the user to submit the feedback to Teneo Engine if they decide to close the chat. Regarding its format, see the description of theadd_message
method in the TWC API. A possible value can be as follows:
json
1{
2 "type": "modal",
3 "data": {
4 "title": "FEEDBACK",
5 "text": "Have you received the answer you were looking for?",
6 "button_items": [
7 {
8 "style": "secondary",
9 "title": "Yes",
10 "postback": "yes",
11 "parameters": {
12 "command": "userFeedback",
13 "feedbackRating": "positive",
14 "abortActiveFlows": "true"
15 }
16 },{
17 "style": "secondary",
18 "title": "No",
19 "postback": "no",
20 "parameters": {
21 "command": "userFeedback",
22 "feedbackRating": "negative",
23 "abortActiveFlows": "true"
24 }
25 },{
26 "style": "secondary",
27 "title": "Close anyway",
28 "postback": "close",
29 "operation": "closeFrontend"
30 },{
31 "style": "secondary",
32 "title": "Cancel",
33 "postback": "cancel",
34 "operation": "cancel"
35 }
36 ]
37 }
38}
39
askCloseLiveChat
: the confirmation dialog that appears if the user clicks the close button of the frontend in the Live Chat mode and the backend session is assumed to be expired or about to expire because the time elapsed since the last request to Teneo Engine is greater thannMaxWaitedMillis
. The goal of this dialog is to prevent the user from accidentally closing the Live Chat. Regarding its format, see the description of the "add_message
" method in the TWC API. A possible value can be as follows:
json
1{
2 "type": "modal",
3 "data": {
4 "title": "Confirm",
5 "text": "Do you really want to close the chat?",
6 "button_items": [
7 {
8 "style": "secondary",
9 "title": "Yes, close it!",
10 "postback": "close",
11 "operation": "closeFrontend"
12 },{
13 "style": "secondary",
14 "title": "Cancel",
15 "postback": "cancel",
16 "operation": "cancel"
17 }
18 ]
19 }
20}
21
Additional convenience functionalities
There are several other output parameters that can be used for some convenience functionalities.
reset
: If this output parameter is not empty, it causes the frontend to close, terminating the Virtual Assistant backend session.minimize
: If this output parameter is not empty, it causes the frontend to minimize without terminating the Virtual Assistant backend session.