workshop-ai-100

Create Intelligent Bots with the Azure Bot Service

Learn about QnA Maker and how to integrate it with a bot

In this module, you will:

Create a QnA knowledge base

Let’s create a QnA Maker knowledge base (KB).

  1. Go to the QnA Maker portal.

  2. Select Sign in in the upper-right corner and sign in with your Azure credentials.

  3. Unless you already have a knowledge base (KB), the portal will point out that you don’t have any.

Creating a knowledge base and QnA Service

  1. In the menu at the top of the portal, select Create a knowledge base.

  2. Select Create a QnA service. Selecting this button takes you to the Azure portal and signs you in with the credentials you used earlier. You create the QnA Maker service and the associated Azure app service that will host it in this portal. You can also create a QnA Maker service in the Azure portal before you create a knowledge base.

Provide the QnA Maker service details

  1. Provide these details to create the QnA Maker service:

After a brief deployment process, your resource will be created for the service.

Connect the QnA Maker service to the knowledge base

  1. Return to the QnA Maker web portal tab and refresh the page.

  2. The page will refresh. Scroll down to Step 2.

  3. The entries under Step 2 won’t be filled in, but a link to the account information will be populated.

  4. Select your Azure Directory ID, subscription name, and the name of the new QnA service you created earlier.

  5. In Step 3, give your knowledge base a name. We’ll use the Microsoft Bot FAQ, so you can name it BotFAQ.

Populate the knowledge base

  1. We need some data for our KB. We’ll use an existing FAQ as a sample.

  2. Download the Microsoft Bot FAQ zip file and extract it to your local computer.

  3. In Step 4 of the QnA web portal process, select Add file, locate the Word document that you extracted in the previous step, and add the document as a source to populate your KB.

  4. Under Chit-chat, select The Professional to add a predefined personality to your KB. Chit-chat adds responses for messages like hello and goodbye.

  5. Select Create your KB.

After a short time, your KB will be created and the Edit page will load.

Test your knowledge base

  1. To get an idea of how a bot might respond to questions, select Test in the upper-right corner.

  2. A test panel opens, ready for a question.

  3. Enter Hello and select the Enter key. QnA will respond with “Hello.”

  4. Enter when will v3 retire? and select Enter. QnA will respond with a message about v3 updates and release information.

  5. Enter what is included in v4? and press Enter. Read the response.

You can continue to test the interaction by asking questions and evaluating the responses to get an idea of how the QnA KB is polled for answers.

Publish a knowledge base

Now that you’ve created a QnA knowledge base, it’s time to publish it so you can access it from a client application.

  1. On the QnA Maker Knowledge base page, where you were testing in the previous exercise, select PUBLISH in the menu at the top of the page.

  2. Read the message on the next page. It indicates that your KB will move from test to production. It also points out that your KB will be available as an endpoint that you can use in apps and bots.

  3. Select Publish.

  4. After a short time, a success message will appear (if no errors occur).

  5. Note the URL information that appears. You can use the information provided to test the KB with Postman or curl.

If you need to, you can select Edit Service to go back to the KB and make edits.

Integrate QnA with a bot

Now that you’ve created and published your QnA knowledge base, it’s time to learn how to integrate it with a bot. In this exercise, you’ll create a chatbot on the Azure to integrate with the QnA Maker knowledge base you created earlier.

  1. In the QnA Maker portal, go to the Publish page, and publish your knowledge base, if it is not already published.

  2. Select Create Bot. The Azure portal opens with the bot creation configuration.

  3. Enter the settings to create the bot:
    • Give your bot an appropriate name
    • Choose the Subscription service you have been using for this course
    • Select the proper Resource Group
    • Choose the location for the bot. Remember that it’s best to use the same location as your other services
    • Select F0 pricing tier
    • The app name should auto-populate
    • Choose C# as the SDK language
    • Leave the remaining fields at their default.
  4. Click Create. In a few minutes, your bot should be created.

Chat with the Bot

  1. In the Azure portal, open the new bot resource from the notification.

  2. From Bot management, select Test in Web Chat and test the QnA by asking the bot questions