Have you seen webpages with lots and lots of Frequently Asked Questions? Is that really what your customers want? Are you sure that they are reviewing all those before reaching out to your customer service agents?

How do we make searching through the FAQs more engaging and less painful for your customers?

In this era where AI services are in the verge of getting democratized, this is relatively a simple problem to solve.


QnAMaker is one of the Microsoft’s cognitive services that parses through online FAQ webpages, product manuals or other files in formats .tsv, .pdf, .doc, .docx, .xlsx and automatically generates question and answer pairs and stores them efficiently. When we integrate a Bot with the QnAMaker Service, the bot can answer questions for your customers without making them skim through all the FAQs.

Let’s take advantage of this cognitive service to solve our problem.

Here is an example of a bot integrated with QnAMaker service responding to the customer’s question regarding the Desktop Support.

As Dynamics 365 Customer Service module is becoming more of a standard to manage the knowledge articles and cases, let’s see how we can use Dynamics 365 as our backend to act as the source of knowledge articles for the bot.

Note: You will need a basic exposure to Dynamics 365 and Dynamics 365 Portals to follow along this post.

Here is an outline on how we are going to set this up:

  1. To begin with, we need a Dynamics 365 instance with a few sample knowledge articles.
  2. We need to have the Portal solutions installed in the Dynamics 365 instance.
  3. In Dynamics 365, we will create a new web page that retrieves all the Knowledge Articles using liquid template and renders on the page.
  4. Next, we will configure a QnAMaker service that is configured to extract all the knowledge articles that our web page exposes and creates a Knowledge Base with question and answer pairs.
  5. Create a Bot application that integrates with the Knowledge Base that the QnAMaker service created for us in the above step. This allows our customers to interface and ask questions and get the appropriate answers from the Bot.

Portal Setup

Create a new Web Page record.

Create a Page Template record.

Create a Web Template record.

Here is the liquid template code for the Web Template. This liquid code fetches all the knowledge articles and formats it as FAQs.

{% fetchxml KB_Query %}
<fetch version="1.0" mapping="logical">
<entity name="knowledgearticle">
<attribute name="knowledgearticleid" />
<attribute name="title" />
<attribute name="content" />
<order attribute="title" descending="false" />
<filter type="and">
<condition attribute="isrootarticle" operator="eq" value="0" />
{% endfetchxml %}
{% for item in KB_Query.results.entities %}
<h3>{{ item.title }}</h3>
<p>{{ item.content }}</p>
{% unless forloop.last %}{% endunless %}
{% endfor -%}
view raw FAQ Template hosted with ❤ by GitHub

When you navigate to the portal link with the “kb” as partial url as shown below, you should see the knowledge articles in a flat FAQ format.

This is the web page that we will use to configure our Knowledge Base in the QnAMaker Service.

QnAMaker Configuration

Let’s review all the necessary configuration to setup a Knowledge Base using QnAMaker Service.

Go to https://www.qnamaker.ai/Create

Click on the “Create a QnA Service” button which takes you to the Azure Portal prompting you to create QnAMaker Cognitive Service.

This creates 3 services under the hood.

Now, get back to the QnAMaker website and select your appropriate Microsoft Azure Directory IDAzure Subscription NameAzure QnA Service (The QnA Service that you just created).

Note: If you do not see the QnA Service that you just created in the dropdown, refresh the web page to reload.

Type the name of your Knowledge Base

Provide the web page link where you have all your knowledge base articles listed. In our case, this is the portal web page that has all our KB articles listed in the FAQ format.

Opting for Chit-Chat adds a dataset that handles generic question and answer pairs to your bot that makes it more conversational and engaging. For instance, the bot will respond when your customer says “Hi” or “How are you?”. There are different levels of dataset you can add, for the purpose of this post, I am choosing “The Friend”.

You may skip this if you choose to.

Finally, click on “Create your KB” button. This step crawls the FAQ Webpage URL and extracts the KB dataset into Question and Answer Pairs in the Azure Search Service and indexes it.

Once done, it should take you to the the Knowledge Base page with the Question and Answer Pairs.

Test button enables us to try out our Knowledge Base before publishing it to the production instance. Click on the Test tab and ask a question. You should see the appropriate response.

Click on Publish Tab.

Clicking on Publish will create an Endpoint to allow us to integrate the QnAMaker with the bot application.

This box contains all the necessary details in order to integrate the Bot with this Knowledge Base.

Now, the Knowledge Base is setup with the QnAMaker Cognitive Service.

Bot Development

Go to the Bot Builder Sample Github page and download the QnAMaker Sample project – https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/11.qnamaker

This bot sample demonstrates how to connect to the QnAMaker service and to answer questions based on the Knowledge Base configured in the QnAMaker.

Open the QnAMaker.Bot File. This .Bot file contains all the necessary configuration parameters to connect to the QnAMaker KB that we created a while ago.

Go to the QnAMaker website – https://www.qnamaker.ai and click on My Knowledge bases.

Click on View Code link on the Knowledge Base that you created.

A popup that contains all the necessary configuration parameters will show up.

In the above image:

There is another parameter that you require – subscriptionkey, which is not available in the QnAMaker interface, but you can obtain it from the azure portal.

Once logged in to the azure portal, open the QnAMaker Cognitive Service that you created.

Navigate to Keys and copy the Key as shown in the screenshot below:

This key will act as your subscriptionkey.

Set the above parameters accordingly in the QnaMaker.Bot file in the Bot Sample code.

Ensure that the name is set to “QnABot”.

Press F5 to run the QnAMaker sample application


Download the emulator from here, if you do not have it already.

Click on “create a new bot configuration”

Complete the fields as shown below:

The Endpoint URL shown in the above image is very important. Most commonly “http://localhost:3978/api/messages&#8221; will be the url unless you dived in and changed it.

Click on Save and connect button and when it prompts you for the location to save, create a folder named “QnAMaker” in the desktop. This will save a .Bot file in this location. Please note that if you happen to save this .Bot file in the same location as the QnAMaker sample source code, the application throws an exception while running as it tries to parse the qnamaker.bot file and this .bot file that you newly saved.

Once the .Bot file is saved, the emulator opens a new Chat Session and the bot sends you a welcome message.

Go ahead ask say “Hi” and “How are you doing?” and the bot will respond appropriately. This is possible out of the box because of the chitchat that we added when we setup our Knowledge Base in the QnAMaker service.

Now, ask one of your questions from the knowledge base stored in the Dynamics 365 and you should find the appropriate response from the bot. This is due to the fact that the QnAMaker extracted all the knowledge articles from Dynamics 365 and created a KB with question and answer pairs, which we integrated with our bot application.

That’s it. Problem Solved!

In this post, we reviewed how to integrate Dynamics 365 Knowledge Articles with the bot application using QnAMaker Cognitive Services to develop much more engaging and efficient approach to search FAQs. This is one example to demonstrate how cognitive service integrates with the bot framework to extend the bot’s capability.

Happy Holidays!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s