Integrating with QnA Maker
Overview
Since Azure QnA provides a set of services that might assist both inbound guests, as well as service desk agents, with resolving common issues or questions. Chime provides native integration with Azure QnA in the following areas
Guests interacting with Chime
For inbound guests looking for help:
- QnA may be attached as a tab on the Chime web client
- QnA may be exposed as a bot and Chime can invoke this bot as part of the queue configuration
- QnA may be attached as part of a Chime queue interview.
- Guests can chat with QnA bot through MS Teams.
- QnA Bot Can be Exposed Before Interview.
QnA Tab on Chime Web Client
QnA Exposed as Bot in Queue Configuration
(see Associate QnA Instance with Queue below)
QnA Routed From Interview.
To add an option for QnA help to a Chime interview:
- Open queue settings, navigate to the Interview tab
- Add a new option to the dialog from which you wish to route to QnA, select "Go to Bot" form the action menu, and select the QnA bot that you previously configured. In this example, we titled the option, "QnA help," but you may specify another name.
After a guest initializes a chat, they would see a Chime interview with an option to get QnA help. For example:
Selecting the QnA help option routes the chat to your QnA bot.
QnA Bot Exposed Before Interview
The QnA bot, configured as an external Azure Appservice Bot, can be exposed before the Chime Interview. The QnA bot will initialize at the beginning of all chats, with an option to route to an agent. To configure this setting, navigate to the Integration tab of Queue Settings and select the option to invoke the bot before welcome message. Select the Add Bot option and choose a bot that has been connected to your queue to greet guests.
Chatting With QnA in Teams
Guests may be routed to the QnA bot in MS Teams through the interview.
Once guests are chatting with the QnA bot in MS Teams, the chat experience is similar to that of the web client.
##Chime Managers and Admins For Chime Managers and Admins
- QnA instances can be integrated directly into Chime (See Administrator: Attach a QnA Maker Knowledge Base to Chime below).
- Once a QnA instance is registered with Chime, the instance may be exposed via the web client for use by both agents and guests.
- If the QnA instance is also published as a bot, then this bot may be connected like any other Bot Framework bot. See the wiki entry on Integrating External Bots for more info on connecting Bot Framework bots to Chime.
##Agents
- Agents have an additional QnA tab on their agent context window that provides a web based UI to the QnA instance attached to the queue:
Agents can utilize the QnA resource by entering text prompts. Responses from the QnA Generate Answer API populate directly in the agent window:
Adding QnA Bots to Chime
Gather QnA Knowledge Base Info
Before adding a QnA Maker bot into Chime you will need to get the credentials for you QnA Knowledge Base Go to www.qnamaker.ai/Home/MyServices and copy the Knowledge Base Name, Knowledge Base ID, Host URL, and Endpoint Key
#Administrator: Attach a QnA Maker Knowledge Base to Chime This section will cover how to add in a QnA Maker knowledge base and attach it to a queue before guests route into live agents
- In the Chime web app, navigate to the Admin section, then QnA Maker
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/admin-qna.png"/>
- Click Add Knowledge Base
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/add-kb.png"/>
- Enter in the Knowledge Base Name, Knowledge Base ID, Host URL, and Endpoint Key
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/enter-kb-info.png"/>
- Click Verify Settings and then Save
- Your Knowledge Base will be added to the list of Knowledge Bases
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/added-kb.png"/>
#Associate QnA Instance with Queue
- Go to Queue Settings of the Queue you want to integrate with, then selet the Cognitive tab
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/manage-queues-qna.png"/>
- Click the Add Knowledge Base button and select the Knowledge base you want to use
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/cognitive-add.png"/>
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/cognitive-select.png"/>
- Save the settings and your knowledge base will be assigned to the queue
<IMG src="https://addchime.com/assets/img/ss/teams/QnA-integration/cognitive-added.png"/>
- When you start a chat session, the Knowledge Base will attempt to help the guest based on the initial question they ask
Tips and Tricks
Here is a collection of tips that users may find helpful for getting best results with Chime and QnAMaker.
External Bot Messages Text Resource
The styling of messages sent to guests from external bots can be configured using Chime's built in text resources. To change the styling of those messages, navigate to Queue Settings -> Text Resources, and edit the text resource titled, "External Bot Messages".
The JSON for the Adaptive Card pictured above is below for reference.
"type": "AdaptiveCard",
"backgroundImage": "https://www.solidbackgrounds.com/images/950x350/950x350-light-gray-solid-color-background.jpg",
"body": [
{
"type": "TextBlock",
"weight": "Bolder",
"text": "@Model.BotName"
},
{
"type": "TextBlock",
"text": "@Model.Text",
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Connect with an agent",
"data": {
"msg": "/agent"
}
},
{
"type": "Action.Submit",
"title": "End Chat - Issue Resolved",
"data": {
"msg": "/end"
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
Hotfix for Default QnAMaker Bot
Users who opt to use QnAMaker's automatic bot generation feature may notice some occasional odd responses from the chatbot. As generated by QnAMaker, the bot responds to some of the slash-commands that are built directly into the Chime QnAMaker interface. For example, choosing to route to an agent sends a message, "/agent" to Chime. To configure your chatbot to ignore these common slash-commands, insert the following code block into the index.js file in your Azure appservice at lines 85-86:
In addition to ignoring Chime slash commands, you may also want to ignore or disable the QnA Maker default welcome message. It is because the default code is setup so that it sends a welcome message whenever a new user is added to the bot conversation. This means that guests will receive multiple welcome messages since in a Chime conversation, you have multiple users such as guest and a bot or a dispatcher. To ignore the welcome message, you will need to open the QnA Maker bot class file, which in this case, it is ./bots/qnaBot.js
. And finally comment the sendActivity
command on line 44 located inside the onMembersAdded
bot handler method as shown below:
The app service code can be accessed through the Azure AppService Editor in AppService Developer tools. NOTE: Although the App Service Editor allows users to deploy code edits through the editor itself, we recommend using FTP to pull down the AppService code to make changes locally before deploying edited code.