QnA Maker

Start course

In this course, you will learn how to create a chatbot to answer support questions about specific products and services. Along with this, you will learn how to combine the Azure Bot Service and Azure QnA Maker and to add speech input and output capabilities to help customers on mobile devices and those with impaired sight.

This course requires some previous knowledge of Azure and coding.

Learning Objectives

  • Create and configure an Azure QnA Maker knowledge base
  • Create an Azure Bot Service chatbot that answers questions
  • Enable speech recognition and synthesis on an Azure chatbot

Intended Audience

  • Those interested in artificial intelligence services on Azure, especially chatbots


  • Previous experience using Azure
  • Previous experience with writing code


The GitHub repository for this course is at https://github.com/cloudacademy/azure-chatbot.


You might think that our first step would be to create a bot. We could do that, but it probably makes more sense to build a knowledge base first and then create a bot that uses it. As I mentioned earlier, we can use QnA Maker to do that.

Go to the QnA Maker portal, which is at qnamaker.ai. Click “Get started”. Now click “Create a knowledge base”.

The first step is to create a QnA service in Azure. We could have created one first using the Azure Portal, but it’s more convenient to do it through this interface. It opened up the Azure Portal for us.

I’m going to create a new resource group so it will be easier to delete everything when we’re done.

The name of your QnA Maker instance has to be globally unique. I’m going to call mine “ca” (for Cloud Academy) “qna”. You’ll have to choose something else. 

There are two pricing tiers available. Choose the free one. You also have to choose a pricing tier for the search service. That’s because QnA Maker automatically creates an Azure Search service for you. Choose free again.

It also creates an App Service app for you, but you can’t change the pricing tier from here. You have to go to the App Service and change it once it’s created. You’ll notice that it set the app name to be the same as the name we filled in above.

This last part is to enable Application Insights, which is a performance analysis tool for apps. If we were building a production app, then I’d probably enable it, but since it’s just a demo, I’m going to disable it. Then click “Review + create” and “Create”. It takes a little while to create everything, so I’ll fast forward.

OK, it’s done. Now go to “Resource groups” and click on the one you created. You can see that it created 4 resources: QnA Maker, an App Service app and its associated plan, and a Search service. Now that everything is ready, we need to create a knowledge base.

Like all of the cognitive services, QnA Maker is accessed by using an API. The documentation gives example code for C#, JavaScript, Python, Ruby, and Go. But we’re going to go back to the QnA Maker portal to create a knowledge base.

Now we have to connect the QnA service we created to the knowledge base we’re creating. First we have to click the “Refresh” button since we opened this page before creating the QnA service. Okay, now pick the tenant in Azure Active Directory. I only have one, so that’s easy. Then choose the subscription. You might only have one in your list. Now the QnA service you just created should show up in this dropdown. And finally, select “English” for the language.

Give your knowledge base a name. I’ll call mine “KB demo”.

Here’s where we finally tell it which questions and answers to put in the knowledge base. We’re going to add the FAQ for QnA Maker itself, which is kind of meta, don’t you think? You can find the URL in the GitHub readme file I showed you earlier. Let’s also add the FAQ for the Azure Bot framework. If you have questions and answers in files, then you can add them here.

There are some other options as well. First, there’s multi-turn extraction. You need to enable this if some questions can only be answered after the bot gets more information from the user. For example, suppose that a common question is, “How do I sign in to Azure?”, and the answer depends on whether the person is using a web browser or the Azure App. You could simply have the bot give answers for both methods, or you could have the bot ask the user whether they’re using a web browser or the Azure App before it gives them the answer. This is called a multi-turn conversation.

It’s possible to extract multi-turn questions and answers from a document but only if the document is structured in the right way. It has to have headings and subheadings to let QnA Maker know the hierarchy of the questions, answers, and clarification prompts. If you need to add multi-turn conversations, then you can click this link to get more information.

Another option is called chit-chat. You can choose a personality, such as professional or witty, and it will add a set of responses to common questions. For example, if you choose the professional personality, and a user asks “What should I do?“, the bot will say,  “​​I wouldn’t know how to advise about this.” But if you choose the witty personality, the bot will say, “My advice is probably about as valuable as a fortune cookie.”

All right, now click “Create your KB”. I’ll fast forward again.

You can see that it extracted the questions and answers from the FAQs. You can also add questions and answers manually if you want, but we’re not going to do that. Another option is to add alternative phrasing. This means you can add more questions that come back with the same answer. For example, suppose that we added a QnA pair such that when the user says “hello”, the bot says “hello” back, then we could add alternative phrasings, such as “hi” and “howdy”, that would also result in the bot coming back with “hello”.

All right, now you can test the knowledge base very easily by clicking “Test”. Now type something in and see what it comes back with. Let’s try “voice”. Hmmm, it didn’t find anything about voice in the knowledge base. How about seeing what languages are supported in QnA Maker. Now it came back with something.

Okay, it seems to be working, so click “Save and train”. You can get rid of the test window by clicking “Test” again. 

Okay, it’s done. Before we publish it, I’ll show you something else. If you need to change the configuration of your knowledge base, then go to Settings. You’ve already seen most of these, but here’s something new. If at some point you want to migrate your knowledge base to another region, you can export it here. Then you can create a knowledge base in another region and go to its settings to import the file you saved.

All right, now we need to publish our knowledge base so we can connect it up to a bot. Click the “Publish” button.

Note that whenever you make changes to your knowledge base, you need to train it and publish it again.

That was fairly quick. It came back with a sample HTTP request to send a question to the QnA service.

All right, I’m just going to show you one more thing before we move on. Under “Service Settings”, there’s an option called “Active Learning”. If you enable it, then QnA Maker will learn from user interactions with your knowledge base and suggest some alternative questions to add. You can then review these suggestions and decide whether to add them or not. Remember when I showed you how to add an alternative phrasing to a question? Well, if you accept an active learning suggestion, then it will be added as an alternative phrasing to an existing question.

Okay, if you’re ready to create the bot, then go to the next video.

About the Author
Guy Hummel
Azure and Google Cloud Content Lead
Learning Paths

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).