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.

mitel

Prerequisites

These instructions assume your Teneo solution is published and that you know the Engine URL.

Setup instructions

Frontend

  1. 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:
    const nMaxWaitedMillis = 540000;
  2. Deploy TWC as per these instructions.
  3. 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):
    <script src="/path/to/teneo-web-chat.js"></script>
    ...
    <script src="/path/to/twcMitelExtension.js"></script>
    ...
    <script>
    // The TWC initialization code
    ...
    window.TeneoWebChat.initialize(...);
    ...
    </script>

Teneo Engine

Initialization

Implement the following global configurations:

  1. Upload submitAdd.jsp and submitAssign.jsp into the / folder of your solution (not into /views where JSPs are uploaded by default).
  2. Add the content of MitelChatAux.groovy to the 'Solution loaded' script.
  3. 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):
// Customer chat configuration (set your own property values):

mMitelChatConfig = [
    "sChatBaseUrl": "https://your-mitel-chat-service.com/ChatService/",
    "sCustomerID": null,
    "sCustomerName": null,
    "sEmailAddress": null,
    "sPhoneNumber": null,
    "nTenantID": 0,
    "nServiceGroupID": 0,
    "sServiceGroupName": "",
    "sPrivateData": null,

    "sSessionID": null
];

// Estimated time in seconds to wait for a live chat agent (-1 if it cannot be estimated):

nEstimatedWaitTime = -1;

// The stringified JSON object to be returned in the output parameter "mitelLiveChatData"
// to start the live chat handover in the TWC frontend:

sMitelLiveChatData = "";

// Possible error:

mitelError = null;

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 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:

nEstimatedWaitTime = -1;
mitelError = null;

String sUrl = mMitelChatConfig.sChatBaseUrl;

if (sUrl) sUrl += 'GetQueueInfo'
else throw new RuntimeException('MitelChatAux, mMitelChatConfig has no sChatBaseUrl');

Map requestParam = new HashMap();

if (mMitelChatConfig.nTenantID != null) requestParam['TenantID'] = mMitelChatConfig.nTenantID;
if (mMitelChatConfig.nServiceGroupID != null) requestParam['ServiceGroupID'] = mMitelChatConfig.nServiceGroupID;

def dto = [request: requestParam];

String sBody = new groovy.json.JsonBuilder(dto).toString();

requestParam = dto = null;

try {
    def x = MitelChatAux.fetchJsonFromUrl(sUrl, sBody).d;
    nEstimatedWaitTime = x.EstimatedWaitTime;
} catch(Exception ex) {
    mitelError = ex;
}

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 variable sMitelLiveChatData:
sMitelLiveChatData = '';
mitelError = null;

String sUrl = mMitelChatConfig.sChatBaseUrl;

if (sUrl) sUrl += 'RequestChat'
else {
    mitelError = new RuntimeException('mMitelChatConfig has no sChatBaseUrl');
    throw mitelError;
}

Map m = new HashMap();

if (mMitelChatConfig.sSessionID != null) m['SessionID'] = mMitelChatConfig.sSessionID;

if (mMitelChatConfig.sCustomerID != null) m['CustomerID'] = mMitelChatConfig.sCustomerID;
if (mMitelChatConfig.sCustomerName != null) m['CustomerName'] = mMitelChatConfig.sCustomerName;
if (mMitelChatConfig.sEmailAddress != null) m['EmailAddress'] = mMitelChatConfig.sEmailAddress;
if (mMitelChatConfig.sPhoneNumber != null) m['PhoneNumber'] = mMitelChatConfig.sPhoneNumber;
if (mMitelChatConfig.nTenantID != null) m['TenantID'] = mMitelChatConfig.nTenantID;
if (mMitelChatConfig.nServiceGroupID != null) m['ServiceGroupID'] = mMitelChatConfig.nServiceGroupID;
if (mMitelChatConfig.sServiceGroupName != null) m['ServiceGroupName'] = mMitelChatConfig.sServiceGroupName;
if (mMitelChatConfig.sPrivateData != null) m['PrivateData'] = mMitelChatConfig.sPrivateData;

String sBody = new groovy.json.JsonBuilder([request: m]).toString();

try {
    def mitelLiveChatDataContainer = MitelChatAux.fetchJsonFromUrl(sUrl, sBody);

    m.putAll(mitelLiveChatDataContainer.d);
    m.sChatBaseUrl = mMitelChatConfig.sChatBaseUrl;

    // Set to true if you want to see debug info in the browser console:

    m.bDebug = false;

    // Create a stringified JSON-formatted config (containing the chat session ID)
    // to return to the FE in the output parameter "mitelLiveChatData". This object is
    // used to create an instance of the Mitel chat handler class:

    sMitelLiveChatData = new groovy.json.JsonBuilder(m).toString();
} catch (err) {
    mitelError = ex;
}

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 the add_message method in the TWC API. A possible value can be as follows:
{
    "type": "modal",
    "data": {
        "title": "FEEDBACK",
        "text": "Have you received the answer you were looking for?",
        "button_items": [
            {
                "style": "secondary",
                "title": "Yes",
                "postback": "yes",
                "parameters": {
                    "command": "userFeedback",
                    "feedbackRating": "positive",
                    "abortActiveFlows": "true"
                }
            },{
                "style": "secondary",
                "title": "No",
                "postback": "no",
                "parameters": {
                    "command": "userFeedback",
                    "feedbackRating": "negative",
                    "abortActiveFlows": "true"
                }
            },{
                "style": "secondary",
                "title": "Close anyway",
                "postback": "close",
                "operation": "closeFrontend"
            },{
                "style": "secondary",
                "title": "Cancel",
                "postback": "cancel",
                "operation": "cancel"
            }
        ]
    }
}
  • 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 than nMaxWaitedMillis. 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:
{
    "type": "modal",
    "data": {
        "title": "Confirm",
        "text": "Do you really want to close the chat?",
        "button_items": [
            {
                "style": "secondary",
                "title": "Yes, close it!",
                "postback": "close",
                "operation": "closeFrontend"
            },{
                "style": "secondary",
                "title": "Cancel",
                "postback": "cancel",
                "operation": "cancel"
            }
        ]
    }
}

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.

Was this page helpful?