Creating FAQ Bot With BOT Framework's QnA Maker

Introduction

Recently I have attended Azure Tech Day event in Mumbai, where in Cortana session I came to know about QnA maker provided by Microsoft Bot Framework using Microsoft Cognitive Services. Playing with it for few hours, really found it fantastic to work with.

In this tutorial, will work with Botframework’s QnA maker to create our own QnA Bot.

Pre-requisite

  • Zeal to learn Bot Framework.
  • Microsoft Live Account.

Create your first QnA bot

Go to https://qnamaker.ai/ OR qnamaker.botframework.com; both lead to the same web portal.

Click on ‘Create new service’.


If you are not logged in, it will ask to log in with Microsoft Live account.

After successful login, QnA Maker will require some basic permissions to get started. Read those permission details carefully and click on Yes to proceed.


Now, QnA Maker will ask to agree with Microsoft Cognitive Terms and privacy statement, as QnA maker is provided under Cognitive Services terms. Check the ‘I agree.’ checkbox and hit on continue to proceed with.


Now, you will landed over to main page where in you can start with creating your own QnA Bot.


Let’s name the service

The first item is naming your service (mandatory). This name will appear as Bot response.


Feeding data

For feeding the data to QnA bot, there are three methods or ways available. We can use any one method or combinations of all three methods as per the requirement.

  • FAQ URLs

    This will help us gather relevant data about your business and extract QnA pairs that you can later use in your bot. Now this is really cool, we can enter one or more URLs to existing, publicly accessible, FAQ style pages; Assuming or considering the URL are with “FAQ” type HTML structure, QnA Maker service can extract the Qs and As crawling into the same.



    For this tutorial, we will be entering Hexaware Technologies' career FAQ section, http://hexaware.com/careers/faq

    You can enter multiple URLs also. Clicking on ‘+Add another’ will allow you to add multiple URLs. Once done with entering URL, hit on "Create" button, if you are going with only one method.

    For this tutorial, will go one by one selecting the available methods.

    Hitting on ‘Create’ will lead to this neat message, saying QnA is extracting URLs for feeding data. Now, the time taken for this could vary with size and number of URLs you are entering.



    Once done with extracting QnA pairs, it will land up at below detailed page. As you can see, QnA maker has brilliantly extracted all 9 questions available at provided URL.

    Very first QA is to start with greeting to Bot user. By default it has, ‘Hello’ as a response for ‘Hi’, you can modify with your desired response and click on ‘Save and retrain’ button to update the knowledge base. It has following options available, 

    • Tab name ‘Knowledge base 
      This tab displays all QnA extracted or seeded to QnA maker through any given method and source.

    • Tab name ‘Test’
      Here you can actually test the Bot request response, with all possible matches and even allowing to add multiple questions patterns for the same desired options.

    • Tab name ‘Setting’
      Here, it will display all the basic details, like Service name, URL entered, file name if uploaded. It also provides sample HTTP request for accessing the service once it gets published. Also, you can delete the service from the option available over here in this tab.

    • Button ‘Save & Train’
      This will save and train Bot with all modified changes done to the knowledge base..

    • Button ‘Publish’
      It will publish our Bot, will be available with public HTTP URL and ready to use.



    • Link Button ‘+ Ad new QnA pair’ 
      This allows us to add new set of questions and answers by adding new row to existing QnA set.



      You can also delete any question from the list, or, can add alternate question for the same response by clicking on three dots that appear at right top corner of Test area.



  • FAQ files

    Again, this is super cool, it allows you to take preexisting content, and just import it directly; you can directly upload files containing your question and answer pairs. As of now it supports .tsv, .pdf, .doc, .docx, format each under 2MB. It allows to upload up to five files containing questions and answers in sequence.

    Click on ‘Select file’ and upload desired file with supported format. Hit on Create once done.



    For this article, I have copied demonetization FAQ from RBI site which is publicly available, in to word file name qnafaq.docx and uploaded the same.

    It’s in below format.

    Again, after clicking ‘Create’ it will take few seconds and will land up to knowledge base screen reading data from the document uploaded.



  • Manual Addition

    This is you can very do at any step, also by adding URL or document. As mentioned earlier Knowledgebase page gives provision to add Question Answer, additional phase manually. 

Testing the service

Once done with adding question set with any available method or combination of the same, lets test it how it will respond to given questions.

Go to tab ‘Test’

It provides a cool chat interface, where in you can enter the questions as request and it responds with desired seeded response.

At Left block it will list you all possible response, with highest score on top followed by lowest possible response. You can reorder or select the required response from this block and hit on ‘Save and Train ‘button to train the Bot.

At Right block it will allow us to add additional phrase or question set for the same response. Once added hit on ‘Save and Train ‘button to train the Bot.

This all changes will be reflected at Knowledgebase tab.


Now, let’s ask the first question from the doc uploaded. Refer to the above posted image with sample doc format for entered question and answer.

As seen, we have asked the question and got the exact response as seeded to Bot, outlined with blue. Also, as mentioned earlier, notice the area outlined with Yellow, where all the responses are listed with highest score at top.

And, the area outlined with green is where we can add additional phrase or question for the same response. Here, I have added as ” Why Modi did this to us? “


Once done with adding phrase, click on ‘Save and train’ button to get it seeded.

Now, go to "Knowledge base" tab. Here, you can see the added question with same response.


Will test the same. Going to tab, Test, and entering the newly added phrase.


Cool! Isn’t it.

Now, once done with adding and modifying the knowledgebase, let's publish the same. Click on ‘Publish’ at top. This will lead to a summarize page where it will list total number of QnA added.

Again, click on ‘Publish‘.


Success message with deployment will be displayed along with sample HTTP request URL, which you can use in your Bot application to communicate.

At any given time, you can edit service by clicking ‘Edit Service ‘. These details along with deployment details will be available at ‘Setting’ tab.


You can also view the list of all services created at ‘My Service’ tab. Wherein you can edit, delete or view the sample HTTP request code for the service along with last modified and published details.


Summary

Microsoft Bot Framework has provided this super intelligent QnA Maker to make developers' life easier, for building such intelligent Bot with few clicks. Do read the Documentation for learning how to build your Bot using the above service. 

Will deep dive more in Microsoft Bot Framework and Cognitive services in coming articles. Would encourage to try it out once. You can have your own FAQ bot up and live in just a few minutes.

Hope, you found this useful.

Happy Azure Coding!

Up Next
    Ebook Download
    View all
    Learn
    View all