Microsoft QnA Maker–Creating a Bot for answering frequently asked questions
Published Mar 21 2019 04:48 AM 556 Views
First published on MSDN on Mar 28, 2017

Microsoft QnA Maker Overview

One of the basic requirements in writing your own Bot service is to seed it with questions and answers. In many cases, the questions and answers already exist in content like FAQ URLs/documents, etc.

Microsoft QnA Maker is a free, easy-to-use, REST API and web-based service that trains AI to respond to user's questions in a more natural, conversational way. Compatible across development platforms, hosting services, and channels, QnA Maker is the only question and answer service with a graphical user interface—meaning you don’t need to be a developer to train, manage, and use it for a wide range of solutions.

With optimized machine learning logic and the ability to integrate industry-leading language processing with ease, QnA Maker distills masses of information into distinct, helpful answers.

The QnA Maker cognitive service has fast become the backbone for many customer service bot scenarios.  Once you have created your QnA service and published it, it’s time to incorporate it into your bot framework bot.  To date, there are a couple of ways to implement it from C#.

Watch the following short intro to developing using the QnAMaker

The following tips have been provided by Garry Pretty and documented by Jaime Dalton in the UK Conversations as a Platform team

Getting Started Option 1 – use the Microsoft.Bot.Builder.CognitiveServices nuget package

You’ll then need to create a class that uses the QnAMakerDialog eg:

public class FAQDialog : QnAMakerDialog
public FAQDialog() : base(new QnAMakerService
(new QnAMakerAttribute(ConfigurationManager.AppSettings["QnASubscriptionKey"],
"Sorry I don't understand, please rephrase your question.",
{ }


Then ensure you’ve set the following keys within your web.config:

<add key="QnASubscriptionKey" value="QnASubscriptionKey" />
<add key="QnAKnowledgebaseId" value="QnAKnowledgebaseId" />

Full sample here: ...

Option 2 – use the QnAMakerDialog nuget package by Gary Pretty (MVP)

This has a couple of nice features, such as being able to attribute methods with the QnA confidence score and being able to add attachments to responses.  More of which can be discovered here :

[QnAMakerService("QnASubscriptionKey", "QnAKnowledgebaseId")]
public class FAQDialogGP: QnAMakerDialog<object>
public override async Task NoMatchHandler(IDialogContext context, string originalQueryText)
await context.PostAsync($"Sorry, I couldn't find an answer for '{originalQueryText}'.");

Full sample here:

Interested in learning more about Microsoft Bot Framework


See Jaime Dalton blog who will be updating the method above as the Bot Framework Matures.

Learn More

Hands on Labs for Building a Microsoft Bot

Version history
Last update:
‎Mar 21 2019 04:48 AM
Updated by: