BLOG

Tagged Post

azure

Intelligent Chatbot on Azure

June 19, 2021

Business Problem

Recently one of our customers in Australia came to us to solve a problem that they were facing in the support department. They receive a lot of support requests daily. The solutions for most of these requests are already available in the user manuals, support site, and other materials to which the customers have access. Since many of these requests are easy to fix it’s a struggle to invoice the customers properly. Also, a lot of support staff is needed to meet the demand. Our client wanted us to come up with a solution to this problem.

We looked at the following parameters to suggest a solution.

The channels of support request

The volume of resources (support documents)

The channels of support requests.

  • Microsoft Teams
  • Help desk system
  • Email requests

The volume of the resources

  • Support site
  • User manuals
  • Q&A site

Based on these facts we decided to organize the resources in a manner that a customer would be able to find out the answers using one of the above-mentioned mediums without having to contact the support staff.

Proposed Solution

We proposed an intelligent Chat-Bot that will be deployed on Microsoft Teams and in their Help Desk system. So, the customers would first chat with the bot and the bot would analyze the available resources for possible solutions. If the Chat-Bot failed to respond positively then, it would create a support ticket and assign it to support staff.

Tools

We then looked at the tools that we can use to develop our Chat-Bot. There are plenty of resources out there but, we felt the suite of tools provided by Microsoft are more reliable and easy to use. Microsoft has invested a lot in AI and Natural language processing and has come up with several tools that are ideal to build an intelligent Chat-Bot. Also, it’s easy to test and deploy these tools because of the integration with Azure.

QnA service

QnA service extracts question and answer pairs from the content that you upload. The content can be uploaded as URLs, PDFs, Excel files, SharePoint documents, and many more.

Adaptive cards

Adaptive Card is an open-source toolset that helps apps and services exchange rich snippets of native UI.

Microsoft Teams

Microsoft Teams is a unified communications platform that combines persistent workplace chat, video meetings, file storage, and application integration.

Azure Cosmos DB

Azure Cosmos DB is Microsoft’s globally distributed, multi-model database service. With a click of a button, Cosmos DB enables you to elastically and independently scale throughput and storage across any number of Azure regions worldwide.

Chat Bot Behavior

The ChatBot uses QnA service to query the proposed answers for customer queries. We have used Cosmos DB to store the chat session and related data. It’s deployed to Microsoft Teams as a plugin and is available on the support site as a widget.

Once a user enters the chat room in Microsoft Teams he would be initiating a chat with the Bot. The rest of the flow is as follows,

  • A customer initiates a chat with the bot in Microsoft Teams
  • The customer is greeted and shown a welcome card asking for the name and email address
  • Customer types in his question
  • Chat-Bot responds with an answer or more options to fine-tune the response
  • A customer gives feedback on the answers
  • If Chat-Bot is unable to find the best answer then, A feedback form is displayed
  • A customer fills in the feedback form
  • Chat-Bot creates a support ticket with all the information
  • Send the link to the customer

Implementation

We first created the repository using all the documents, manuals, and URLs. The QnA service allows us to import these different types of resources and generates question and answer pairs. Also, we can extract multipart answers as well so that when a customer asks a question it will be able to refine the answers by giving options.

QnA Maker

We first set up the knowledge base in the QnA maker. Go to https://www.qnamaker.ai/ and click on Create a knowledge base. You must go through 5 steps to set up the knowledge base.

  • Create QnA service in Microsoft Azure
  • Connect your QnA service to KB
  • Name your KB
  • Populate your KB
  • Create your KB
  • Publish your KB

Once the QnA maker is set up it gives us an interactive window to test the chat. Also, we can build a tool to train our Bot using the Train API. In the process of setting up QnA, we need to set up a QnA service in Azure as well. This is an app service where the Bot will be deployed and hosted.

Cosmos DB

Go to the Azure dashboard and set up Cosmos DB instance.

appsettings.json

Bot app is a .Net Core Web API project. Hence, it has the same structure as a Web API Project. The Bot client communicates using JSON.

The request is received by the BotController and passed over to Microsoft.Bot.Builder.IBot instance. This configuration is added in the startup.cs as follows,

services.AddTransient<​IBot, QnABot.Bots.QnABot>();

The IBot instance has three delegates,

  • OnMembersAddedAsync
  • OnTurnAsync
  • OnMessageActivityAsync

OnMembersAddedAsync

This delegate is triggered when a new chat window is created. This is the delegate we use to send a welcome notification to the user.

OnTurnAsync

When implemented in a bot, handles an incoming activity.

OnMessageActivityAsync

This is the delegate that is triggered when a message is sent by the client to the bot.

In our application, we identified 4 chat states which are,

  • User-information
  • Chat-information
  • User-feedback
  • Support-ticket

User-information

This is the initial state. User information is when we capture the user’s name and email and show a welcome message.

Chat-information

Chat information is when we capture user’s requests and send the data to the QnA service. The QnA service would return either response or prompts. This goes on until the user receives the answer he is looking for or he decides to create a support ticket.

User-feedback

User feedback is when we capture whether the user’s request was answered properly or whether a support ticket needs to be created. When the support ticket is created we log the entire chat history in the ticket.

Support-ticket

The support ticket is the step of creating a support ticket in the ticketing system( https://www.servicenow.com/) based on user feedback.

Source Code

Source code can be downloaded from here. Once you download the source code you should do the following.

  • Take a copy of appsettings_dev.json
  • Rename appsettings_dev.json to appsettings.json

#Chatbots #Azure #Luis #Microsoft Bot Framework

Authored by Pragash Rajarathnam @ BISTEC Global

 
Let's talk

We love connecting

We are here to help and support you.

If you believe that we can help you or your businesses requirements - do feel free to drop your details here and don’t hesitate to give us a ring.

Connecting with us on LinkedIn works best.

    • Marlon

      Director

      • |
    • Johann

      CEO | Co-Founder

      • |