Given That, Then… — Building a QnA-style Chatbot, Part 1


| January 19, 2021 | in

Given that you want to create a QnA-style chat, then Azure has a solution for you.

Chatbots are becoming more and more common, but building one from scratch seems terribly complicated. Just the natural language processing alone would be a monumental task. And when you are creating a chatbot, you probably don’t want to become an expert on creating them; you just want to provide a way for customers to interact with an existing knowledge base. Creating an application using Azure is straightforward.

Step 1

Create a QnA service in the Azure Portal.

Given that, then you will end up with three resources in your Azure Subscription.

Step 2

Go to to start building your bot. Once there, you will select your newly created QnA Maker service. From there, you can create a knowledge base. You may find the UI a little awkward since you must click above your previous selection.

Step 3

Build your sample knowledge base.

I quickly created a few KB articles based on a couple of my blog posts.

Step 4

Given that you have created some knowledge base articles, then you need to “Save and Train” your QnA service. Click the Save and train button. Save and train will run your knowledge base content through Azure’s analytical processing. This will build an Azure Search index that can be queried.

Step 5

Given that you have a knowledge base, you can test it. To test it, click the Test button.

Step 6

Given that you have tested your knowledge base, then you can publish it. After publishing, you can run your bot in Postman (an API testing tool) or just using curl. It gives you the code to try, which is nice. Most Unix devs know curl as a quick way to make an HTTP request from a command line.

A curl call can look like this:

curl -X POST -H "Authorization: EndpointKey YOUR_API_KEY" -H "Content-type: application/json" -d "{'question':''}"

Once you have your knowledge base in place, you might find using their UI to be a slow way to build your QnA system out. Luckily you can import and export from a TSV or Excel file.

We have now created a knowledge base that can feed our chatbot. In part two of this series, we will create the actual chatbot.

Related posts