ChatBot - QnA Maker - Conversational AI

In my previous article, we discussed the LUIS integration using SDKs and also implied Image Recognization which is called a custom vision in terms of the cognitive services with help of Microsoft Azure Portal, Microsoft Visual Studio, and BotFramework Emulator. Here, I would like to go with the QnA Cognitive service using just a single tool Microsoft Azure Portal. The term Cognitive Services is very popular.
 

Azure Cognitive Services

 

The Cognitive Services portfolio is growing fast, and services are currently grouped into five categories: Vision, Speech, Language, Decision, and Web Search. We have organized this report around these groupings, but when you are building your app, you are likely to use several services together across multiple categories. There are no restrictions on calling different services together.

Cognitive Services bring AI within reach of every developer—without requiring machine-learning expertise. All it takes is an API call to embed the ability to see, hear, speak, search, understand, and accelerate decision-making into your apps.

Image Reference: Google Images 
 

QnA Maker

 

Customers often try to reach out after working hours to get answers or assistance. Since AI can work 24/7, Friday nights or on Christmas, why shouldn’t we build a chatbot, that acts like a human agent and is able to answer all the questions of the user. As a great example, let me show you a forever customer care: QnA Maker.

QnA Maker is a cloud-based API service that lets you create a conversational question-and-answer layer over your existing data. QnA Maker uses these data to build a knowledge base by extracting questions and answers from your content, including FAQs, manuals, and documents. It answers users’ questions with the best answers from the QnAs in your knowledge base -- automatically. Your knowledge base gets smarter, too, as it continually learns from user behavior.

Examples of client applications include social media apps, chatbots, and speech-enabled desktop applications.

Use QnA Maker when you have static information in your knowledge base of answers. This knowledge base is custom to your needs, which you've, for example, a PDF file.

When you want to provide the same answer to a request, question, or command, QnA Maker is a good choice, especially because when different users submit the same question, the same answer is returned.

If the answer is part of pre-determined conversation flow, represented in your knowledge base with a multi-turn context, a bot can easily provide this flow. You can also set this bot to be able to just chit-chat! Let’s see how this works!!

Example
 
Create QnA maker on Azure, then make a bot for it here.
 
Step 1
 
 
 
This is the first step to create a QnA resource for the chatbot. 
 
Step 2
 
 
Fill the details and select the create button. Waiting for the Deployment of the QnA Bot.
 
Step 3
 
 
Step 4
 
 
 
Our resource is successfully deployed on the Azure Portal. 
 
Step 5
 
Open the link to create a knowledge base. https://www.qnamaker.ai/
 
 
 
Step 6
 
We are skipping the first step while we using qnamaker.ai for the knowledge base. This step is done by us, we already created a resource for QnA service in the Azure portal. Start from Step 2 on this web page. This step connects our resource with the Knowledgebase. Choose the language as English. As we are going to add the file in English language only. 
 
 
 
Next give a unique name to your knowledge base. 
 
Step 7
 
We  have to upload files or an URL in the form of Question and Answer. Kindly check this link where you will find all the relevant files to create a perfect QnA bot.
 
https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/concepts/content-types 
 
 
 
Step 8 
 
To create a chit-chat bot we have to add the file in format .tsv, or else select the personality as None. Create your KB. 
 
 
 
Step 9
 
Check the lists of attached files which you had chosen for the knowledge base.
 
Select Save and Train.
 
 
 
Step 10
 
Select Publish button.
 
 
Step 11(optional) 
 
With using SDKs we have to use these knowledge base IDs for the code snippets file appsettings.json 
 
 
 
Step 12 (optional)
 
While using the Bot Framework Emulator we will get different kinds of answers (personalities) for the same question. 
 
The below image is the combination of three images.
 
 
Step 13
 
Finally, after publishing the KB we have to test our bot in the Web Chat. First, we will get a pre-defined Greeting message from our bot. The blocks in the below image are the customized questions and answers inserted in my .xls file which I added in the Knowledge Base.
 
 
This is all about the beautiful conversation with QnA Bot using Microsoft Azure with any code. It's pretty simple and hardly takes 3-4 minutes to create a QnA Bot in the Web Chat.
 

Summary

 
The purpose of this article to create a knowledge base, then train and test. Publish and then create a bot. Click on Channels and choose to interact via webchat. The same process can be possible using Microsoft Visual Studio and Bot Framework Emulator. Azure Cognitive Services are APIs, SDKs, and services available to help developers build intelligent applications without having direct AI or data science skills or knowledge.