Create your first Azure Chat Bot with QnA Service – Step by Step

QnA

A few days ago, I wrote an article about Create your first Azure Chat Bot – Step by Step followed by Configure LUIS application for practical use in Azure bot. In this article lets explore how can we create an Azure Chat Bot which can respond to any questions based on a known knowledge database using Microsoft QnA Service.

First of all of course you need to have an Azure subscription, you can sign up for free here.

Once you have the subscription ready, go to http://portal.azure.com

Step 1: Create an Azure Chat Bot

  • Browse to New – Data + Analytics – Bot Service

Azure Chat Bot

 

  • Enter the App name, Subscription, Resource Group and Location and press Create

Step 2: Create a Microsoft App ID

  • Once the App gets created, you will get a page similar to this asking to Generate Microsoft App ID and password. Click on the button “Create Microsoft App ID and password”

Create Microsoft App ID

  • It will open a new screen with App name and App ID filled in, note down the App ID and click on “Generate an app password to continue” button

App ID and Password

  • It will show a pop up with new password generated, copy that password too in a notepad, we’ll need both the App ID and the password in next step

Password Generated

  • Click OK on the form and click on “Finish and go back to Bot Framework”

Step 3: Complete Bot Creation

  • Paste the App ID and Password in the fields on the form and select NodeJS as language. You can select C# too, but for this article, we are going to use NodeJS.

NodeJS

  • Scrolling down the page further will ask to choose a template, select “Question and Answer”, check the terms of use and click on “Create bot”

Question and Answer

Step 4: Create QnA Service App

It will show up a window to connect and setup QnA application. You can create QnA application separately as well at https://QnAMaker.ai but if you do it from here, it will just connect the application with your bot automatically. You will need to use the same Azure account to create the application.

  • Click on Sign in

QnA Maker login

  • Type in your Azure portal email address and password and click on the button “Sign in”

Login to QnA

  • Once it’s connected to QnA service, you will see a form asking to create a new Knowledge Base

Create Knowledge base

  • Click on OK and it will create a QnA Service App with a default name. The name of the application can be changed later from the QnA Maker Portal. We’ll see how to do that later in this article. This step will complete the creation of QnA Service App.

Complete Bot Creation

  • Once the provisioning completes, you will see the Bot interface, but we still need a few things to take care of

Step 5: Train the QnA Service App

So, our Bot is up, our QnA Service App is up but we still need to train our QnA Service App to respond to queries. So, lets get to the work.

  • Open a browser and browse to https://qnamaker.ai
  • Login with your Azure Credentials and you would see the automatically created app listed under My services. Click on the Edit Icon.

QnA App Listing

  • By default QnA App has one entry added to respond to “Hi” with an answer “Hello”, neat but we need more from our bot, so lets go ahead and click on “Add new QnA pair”

Edit QnA

  • Type “Does this really work?” (for any other question, you wish) in the Question field and type “Seems so” in the Answer field

Add QnA Item

  • Click on Save and Train button and then Click Publish
  • It will show a summary of items to be published, click publish again

Publish

  • You will get a success message and we are good to go

Step 6: Test the Bot

  • Go back to the Azure portal and open the Chat bot created in Step 1
  • Click on Test and type “Does this really work?” and bot will look into the answer from the QnA service and respond accordingly.

Bot created

  • Feel free to add Microsoft FAQ URLs and your own documents (should be in FAQ format) in the QnA App, retrain and republish and see your bot at work.

Extend QnA Knowledge base

And before I forget, you can change the name of your QnA service app from this settings page as well. That will be the first option on top of the page, just type in any name and click Save and retrain.

Change Name

You don’t need to update anything in your bot as that connects with the QnA service app using it’s KnowledgeBaseId.

You can also connect your bot with Skype Channel as explain at the end of my article Create your first Azure Chat Bot – Step by Step

Enjoy,
Anupam

 

 

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *