Build a FAQ chatbot with QnA Maker and Microsoft Bot Framework

Introduction:

The QnA Maker is a cloud-based service provided by Microsoft that allows you to build a knowledge base (KB) from your data. The knowledge base is simply a set of questions and answers which contain user queries and the relevant responses. The QnA Maker is a popular feature in the Microsoft Bot Framework due to ease of customization and integration with other services such as Skype, Teams, Facebook Messenger, Slack etc.

The QnA Maker is designed to take your structured and semi-structed data, apply different machine learning techniques to it and convert it to a knowledge base. Additionally, it provides you with the ability to manually add questions and answers in the same knowledge base. The QnA Maker exposes the knowledge base as a Restful API that you can consume through any application of your choice.

You can send a POST request to the endpoint along with the query. The QnA Maker processes the query to perform language understanding (LUIS) and other techniques to match that query against a question in the knowledge base. Once the match is found, the QnA maker sends back a response.

Different ways of populating your knowledge base:

The QnA Maker provides three ways in which you can populate or fill in your knowledge base:

  1. Through Web URL’s
  • You can provide links to FAQ pages of the website, the QnA Maker will extract all the questions and answers to build the knowledge base.
  1. Through files
  • You can provide your data in an excel file or comma/tab separated text files. The QnA Maker can parse those files to make a knowledge base. You can also provide PDF and doc files of your product manuals or FAQ’s.
  1. Manually
  • You can manually add questions and answers through a web-based UI in your knowledge base.

The following diagram depicts the architecture of the QnA Maker and its applications with chatbots:

microsoft chatbot

Connecting knowledge base with Microsoft chatbot:

Once your knowledge base is exposed as a Rest API, you can use this in any application of your choice. However, one very popular and useful scenario is to connect your knowledge base with a chatbot.

Microsoft offers an integrated environment for building, connecting, testing and deploying bots all in one place. You can read more about the Microsoft Bot Framework from the following link: https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0

Let’s walk through the steps:

  1. Go to the QnA Maker home page and sign-in with azure account.
  2. Once you successfully sign-in, click on “Create a knowledge base” at the top bar and a new page will appear.
  3. This page will contain all the steps to create your knowledge base.
    • Under step-1, click on the button “create a QnA service” and it will take you to Azure portal where you will provide the name, resource group and pricing tier for the service. Once the resource is created in the portal, come back to the same page and click on the refresh button under step 2.
    • In step-2, select your Azure ID, subscription and the QnA service that you just created.
    • Step-3 will ask you to give your knowledge base a name. Type in any name of your choice.
    • Step-4 provides you with options to populate your knowledge base either through a URL, or by uploading a file. You may choose to leave it empty for now. This step also provides you with a “chit chat” option that lets you pre-populate some generic data depending upon the type of knowledge base you are creating. (Professional, friendly, funny)
    • In step-5, click on “Create your KB” to create your knowledge base. This step may a take few minutes.
  4. After you have successfully completed these steps, you can click on “My knowledge bases” at the top menu to view all your KB’s.
  5. Click on the knowledge base that you just created, and it will take you to the home page of that KB.
  6. Under the “Edit” section, you can add questions and answers manually and under “Settings”, you will have options to populate your KB through URLs/files.
  7. Once you are done adding question/answers in your knowledge base, click on the “Save and train” button.
  8. If you wish to test your knowledge base by asking questions and getting responses, you can use the “test” button. It provides you with a chatbot like UI that responds to queries with the data in the knowledge base.
  9. Once you are satisfied with the test, click on “Publish”. After your model is published, you will see two options there.
    • A “Create Bot” button
    • REST endpoints along with the Authentication key
  10. Click on the “Create Bot” button and it will take you to the azure portal where you can create the bot service.
    • Provide the name of your bot, resource group, pricing tier, choose a language (C-sharp, NodeJS) and click on the create button.
  11. Once your resource is deployed, go to the home page of your bot service.
  12. That’s it, you have the chatbot ready and deployed with your desired knowledge base.
  13. On the right-hand side of the home page, you will see an option for “test in web chat”. This will provide you a chatbot where you can test your bot to see if it is working smoothly with your knowledge base.

 

Microsoft Bot Framework allows many new possibilities for its users through its user-friendly interface. Customization and integration of Bots has never been easier. The framework also offers you SDK’s both in C-sharp and NodeJS to build and customize bots. I hope that you now feel empowered to use the Microsoft Bot Framework to fulfill your needs. If you would like to know more about this function, feel free to leave a comment below.

Happy Building!

Leave a Reply

Your email address will not be published. Required fields are marked *