Creating FAQ Bot knowledge base using Cognitive QnAMaker service

Introduction

In this article will learn about how to create FAQ bot service using the power of QnA Maker cognitive services.(Cognitive QnAMaker service)

Prerequisite

  • Microsoft Live Email ID
  • Zeal to learn

Overview

In this era of modern web technology & fast-growing intelligence components, every organization is in the race to compete & win ahead. Bots plays an important role as a component to provide convenient service with faster and smart capabilities.

Bot is nothing but to automate some program so as to act or react on any action or request. In this article will have a look on most important section in organization’s official website i.e. FAQ. Frequently Asked Questions. Every organization has to convey or present some information with respect to there product, service, roadmaps, careers, events etc. And are mainly in the form of Questions, could be asked by proposed customer or user & answer, to question asked.

If organizations implement a bot for FAQs, and have it in their websites, social channels, just imagine the impression they could have in industry, along with ease to tackle the crowd bombarding with queries with no resource cost. Usually there comes a scenario wherein such FAQs are owned by business domain experts. This domain experts are not always a programmer (to code bot), again not every programmer are domain expert, a complex combination.

Developing a bot involves tedious code & sometimes complex architecture designing. But what if we have something,
a. Easy to build a FAQ bot
b. Not a single line of code.
c. No expertise needed,

Sounds cool right! Yes, Microsoft knowledge base Cognitive service QnAMaker service solves all problem listed above when it comes to creating bot.

QnAMaker service is cognitive service falls in knowledge category. As name suggest it develops question & answers as a knowledge base for FAQ bot. So if you have your FAQ content ready, in any form, web page or document, QnA Maker can create a knowledgebase restful endpoint. All you have to do is hit endpoint with desired questions & get answer as response.

Creating QnA Maker Service
Will create knowledgebase from MVP FAQ page,
Open web browser and enter URL https://qnamaker.ai/

As mentioned above in prerequisites, sign-in with Microsoft Live ID.
It will ask permission for accessing few details, read it carefully and
Click on Yes,

Once you grant qnamaker access, you will be prompted to agree with .NET development services terms & conditions and privacy policies.
It also says about transaction limit per day & per month basis,
Read it all carefully & check on ‘I agree’ checkbox and
Click on Continue

Now you are done with all formalities to use QnA Maker service.
A subscription key would get associated with your account.
Click on Right Top corner on your Account name => Click Subscription Keys.

Subscription Keys, both primary & secondary could be copied, reset from here. We may need this further when calling service from applications.

It will land you to ‘My Services’ section, wherein all future created services will be listed.
As we just signed up, it has no service listed.
Click on ‘Create new service’ for creating new service.

Here we need to provide,
• Service Name: Name of Knowledgebase or Service. We can change this later. For this blog, name it as ‘MVPDemoFAQ’
• URL: As mentioned above, we can have source as Webpage of FAQ content. This URL should be publicly accessible. For instance, we will be providing below FAQ page public URL, https://mvp.microsoft.com/en-us/faq
You can add number of URLs, by clicking link name ‘+Add another’ the only limit is knowledgebase should not exceed 30 MB of data.
Note: The URL web content is extracted only once and its not sync with service with any future updates on web page.
• Along with URL, you can also add files as source for service knowledge base. This file can be in. tsv, .pdf, .docx format.
If. tsv, then should be on Question tab space Answer format. You can download sample tsv format file from link given below,
For any other format, it should be as Question and Answer format.
Will add files as a source when updating the knowledge base.

Below after adding above mention details.

Click on Create to proceed,

Here the tool will extract all question & answer from given URL & files and create a knowledge base for our service. It would act as a brain for out Bot.


In fewer seconds it will extract all the questions & answer from FAQ web page, and creates a knowledge base with questions in one column & answer in next column.
Also, it adds an editorial greet message.
You can change add, modify this knowledge base.
Make sure you click on ‘Save and Train’ button after every addition and modification, so as to update the knowledge base and get trained.

Click on ‘Test’ tab from left tab, to test our knowledge base service in Chat interface.
Chat box opens with greet message being added as our knowledge base.
Just try with entering any question, and you can its answer in response.

You can choose appropriate answer for any questions, and can add multiple questions for same answer. As you keep editing the knowledge base gets updated, only after clicking ‘Save and Train’ button.

Let’s add some different question for above mentioned Question and answer.

Question is, Do MVPs represent Microsoft? We even got the answer. Let’s frame this question in different way like, Can we consider MVPs representing Microsoft? Now for both this question we should get the same answer. But earlier is part of FAQ web page content and later needs to be added now.

To do so, in Test section, at right frame, you can see Text box along with ‘+’ button. You need to add new question over here. And click ‘Save and Train’

Refer below image,

Similarly, if you want to change the answer for Questions in knowledge base, you can do it from Left tab, in the same way.

This modification reflects in Knowledge base tab, by addition of rows & updating contents in columns.

Also, you can manually add questions & answer from this interface too.
Click on “+ Add new QnA pair”
Enter question under Question column and Answer under Answer column.
Click on ‘Save and Train’ button.

Test this, going to Test tab and entering newly added Question in Chat box,

Now once we are done with building our knowledge base, its time to publish it for outer world.
Click on ‘Publish’ button at right hand top of screen next to ‘Save and Train’

This will open up page to review all entries made by different sources.
Once reviewed, click on Publish.

And Whoa! Your Service is ready.

This will provide you with Restful endpoints along with two very important parameters. First the QnAMaker Service ID & QnAMaker Subscription key.

The, two parameters will be the key inputs for connecting knowledge-base with any Bot Framework or application we are calling in from.

Lets now edit the service knowledge base.
There are two ways to edit,
Click on Edit Service button shown in above image, or
Go to Menu, ‘My Services’ => Click on pen icon to edit.

This will allow us to modify service knowledge base, by modifying existing question & answers through Knowledgebase tab.
Also, click on Settings tab.
So here you can do following,
• Change Service Name
• Add more FAQ content Web Public URLs
• Upload any files with supported format to add to knowledge base. (Will be doing this later in article)
• You can share this Knowledge base service with other team members by adding there Microsoft Live email ids.
• Get service endpoints details.
• And also, can delete the created service.

For this blog, I have created two files one with .docx & another as. tsv as format. And added few questions.

I have purposely entered wrong question numbers, so as to show how smartly it extracts the question and answers from the source files.
Click on Select File and upload both files.
Once done with uploading, Click Save and Train.

Navigate to Knowledge base tab, and we can find our file content being added.


Navigate to Test tab, to test our newly added content.

If you notice carefully, I have added a link in response, which as is came from Chat Box as response.
Once done with adding content, click Publish to make the content available for outer world.
Note: Time you don’t publish knowledge base, it will not be available publicly.
Verifying the service calls
Will test our knowledge base service by calling it some outer world entity. For this article will go with Postman tool, for calling service restful endpoint.
Enter the service endpoint, add Subscription key as headers, and body with any question.
Can be seen in below image,


And click on Send to post the request.
You will be getting below as response,
• Answer: An answer for the question posted.
• Questions: Notice carefully there comes two questions as we added two questions for the same answer.
• Score: Score comes as accuracy of response to be a correct answer, from 0 as not an answer to 100 as the accurate answer.

Summary

We learned how easy is to create an intelligent knowledgebase service for our FAQ content, with any form webpage, file, etc as source. In coming article will integrate this knowledgebase service with Azure Bot service and connect to live channels. Till then try this out and be ready with your knowledgebase. Thank you for reading reviews.

Leave a Reply