Question Answering


Start course

The course starts by providing a quick overview of some of Azure’s AI services and what you're going to build.

You'll then be shown:

  • How to create a searchable knowledge base using the question answering service
  • How to create a bot and connect it to the knowledge base
  • How to create a web chat app and connect it to the bot
  • How to enable spoken input and output in the chatbot

Learning Objectives

  • Describe Azure AI services
  • Create a knowledge base using the question answering service
  • Create a bot and connect it to the knowledge base
  • Create a web chat app and connect it to the bot
  • Enable spoken input and output

Intended Audience

  • Azure AI engineers


  • Experience with Azure
  • Experience with writing code (not mandatory)


The GitHub repository for this course is at


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 the “question answering” service to do that.

First, we have to create a Language resource in the Azure Portal. Type “language” in the search bar. There it is. Click “Create”. Select “Custom question answering”. And click “Continue to create your resource”.

Choose an existing resource group, or create a new one. I’m going to create a new one so it’ll be easier to delete everything when I’m done. I’ll call it “demo”. The resource name has to be globally unique, so I’ll call it “ca” for “Cloud Academy”, “demo”. You’ll have to choose something else. For the pricing tier, select “Free”. I’ve already used up my free account, so I’ll have to choose Standard. Now read the Responsible AI Notice, and check the box. Click “Review + create” and “Create”. It’ll take a little while, so I’ll fast-forward.

Okay, it’s done. If we click “Go to resource group”, we can see that it created 2 resources: a Language resource and a Search service. Now that everything’s ready, we need to create a knowledge base.

Go to the Language Studio, which is at Sign in to your Azure account. Fill in your Azure directory and subscription. And select your new Language resource from the dropdown menu. Then click “Done”. In the “Create new” menu, select “Custom question answering”. 

Now we need to decide whether we’ll have any projects in languages other than English. This is important because if we select the English-only option, we’ll never be asked about other languages again, even when we create a new project. If we select the first option, then we can choose the language every time we create a project. For this demo, we’re going to set the language for all projects to English. Click “Next”.

Give your project a name. I’ll call mine “demo”. Click “Next” and “Create project”.

This is where we can tell it which questions and answers to put in the knowledge base. Click “Add source”. You can add documents by specifying their URLs or by uploading files from your desktop.

Another option is called Chitchat. You can choose a personality, such as professional or witty, and it’ll 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.”

We’re going to get questions and answers from the web, so select “URLs”, and click “Add URL”. Let’s add the “Azure Bot framework FAQ”. Here’s the URL.

You can copy it from the GitHub readme file I showed you earlier. Click the “Add all” button. It takes a while to extract the question and answer pairs from the web page, so I’ll fast-forward again.

All right, now if we click on the source we just added, it takes us to the knowledge base. Here are all of the questions and answers. You can manually add more questions and answers if you want by clicking here.

More often, you’ll want to edit the questions that were extracted from the source you provided. You can also add improvements to them, such as alternate questions. These are different ways of asking the same question. The service is actually pretty good at figuring out alternative ways of asking a question, so for example, for the question “How to run a bot offline?”, you don’t have to add “How can I run a bot offline?” as an alternate question because the algorithm will figure it out on its own.

However, when you test your bot, if you ask a question, and the bot doesn’t give you the expected answer, then you should add that particular phrasing as an alternate question. For example, if it doesn’t give the same answer for “How can I test a bot on my computer?”, then you could add that as an alternate question.

Another way to improve questions is to add follow-up prompts. These allow you to create multi-turn conversations. For example, suppose the answer to how to run a bot offline depends on your computer’s operating system. You could add a follow-on prompt that says, “What operating system are you running on your computer?”, and then you could link three new question-and-answer pairs to the prompt, one for Windows, one for macOS, and one for Linux.

Yet another improvement you can make is to add metadata. This will allow client applications to filter answers based on certain criteria. For example, you could add operating system metadata tags to questions. Then, a client application on a Windows device could filter out question-and-answer pairs that aren’t applicable to Windows.

If most of the answers would need to be filtered by an attribute, such as the operating system, then alternatively, you could create a separate project for each value of the attribute, such as Windows or macOS. That is, you’d put all of the question-and-answer pairs for Windows in one project and all of the question-and-answer pairs for macOS in another project. That way, you wouldn’t need to tag them with metadata, and you’d have a very clear separation between the two domains of knowledge. It might take more work to maintain separate projects than to add metadata tags, though, especially if a lot of the questions and answers are the same for both domains, so it’s not necessarily the best solution.

All right, now you can test the knowledge base very easily by clicking the “Test” icon. Check “Include short answer response” if you want it to use AI to summarize answers that it thinks can be shortened. This can potentially make answers more user-friendly.

Now type something in and see what it comes back with. Let’s try “run bot offline”. It came back with the long answer instead of shortening it because it doesn’t always summarize the answer. Now let’s try “How can I test a bot on my computer?” to see if the algorithm can figure out that it should give us the same answer. It gave an answer for a different question, so let’s add it as an alternate question.

Before we do that, let’s see why it came back with the wrong answer. Click “Inspect”. If you scroll down to the bottom of the answer, it shows you a confidence score. It’s 0.09, which essentially means that it’s only 9% confident that this is the right answer for that question. It also lists a couple of other potential answers, and you can see that the confidence scores for those ones are even lower, which is why it didn’t choose either of them.

If we click on “Inspect” for the first question we asked, it shows a confidence score of 0.99, so it was almost 100% confident that this was the right answer.

Okay, now let’s add that alternate question. Here’s the question. Now, we’ll save it, and click “Test” again. Let’s clear our previous chat session and type the question. Now, it came back with the right answer. If we click “Inspect”, we see that it had 100% confidence. That’s because we entered the exact question that we added as an alternate question. If we had reworded it slightly when we asked, then it probably wouldn’t have been as confident.

All right, I should also mention one more thing about adding alternate questions. You don’t necessarily have to come up with them yourself because the question answering service will watch user interactions with the knowledge base and come up with its own suggestions for alternate questions. Go to the “Review suggestions” page to see. Since there haven’t been many user interactions yet, it doesn’t have any suggestions, but this is where you’d find them.

Okay, let’s go back to the knowledge base. It seems to be working, so we should deploy it, but before we do, I’ll show you something else. 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 import the file you saved.

All right, now we need to deploy our knowledge base so we can connect it to a bot. Go to the “Deploy knowledge base” page. Click “Deploy”, and click “Deploy” again. That was fairly quick. Okay, if you’re ready to create the bot, then go to the next video.

About the Author
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).