Add a QnA Maker knowledge base to your bot

APPLIES TO: Composer v1.x and v2.x

This article will show you how to add an existing QnA Maker knowledge base to your bot. Composer provides the Connect to QnA Knowledgebase action which makes the process easy. You will find this helpful when you want to send a user question to your bot then have the QnA Maker knowledge base provide the answer. If you want to create a QnA Maker knowledge base directly in Composer, or connect to one via QnA Maker, see the Create a QnA Maker knowledge base article.

You have the following ways for using QnA in Composer:

  • Using an action. It allows you to make a specific and explicit call to QnA with an action. This option does not allow any authoring or two-way connectivity, it is a simple way to query QnA from an dialog. Also, it does not allow publishing. This is described in this article.
  • Authoring QnA from Composer. This more robust approach allows and requires authoring from Composer, as well as recognition of QnA intents and dialog triggers. This option allows publishing. This is described in the Create a QnA Maker knowledge base article.

Prerequisites

Add QnA Maker integration

To access the Connect to QnA Knowledgebase action, you need to select + under the node you want to add the QnA knowledge base and then select Connect to QnAKnowledgeBase from the Access external resources action menu.

QnA connect to knowledgebase

Review settings

Review the QnA Maker settings panel after selecting the QnA Maker dialog. While you can edit settings in the panel, a security best practice is to edit security-related settings (such as the endpoint key, knowledge base, ID, and hostname) from the Settings menu. This menu writes the values to the appsettings.json file and persists the values in the browser session. If you edit the settings from the QnA Maker settings panel, these settings are less secure because they are written to the dialog file.

Required and optional settings

The following settings configure the bot's integration with QnA Maker.

Required Setting Information
Required Knowledge base ID - provided by appsettings.json as settings.qna.knowledgebaseid You shouldn't need to provide this value. QnA Maker portal's Settings for the knowledge base, after the knowledge base is published. For example, 12345678-MMMM-ZZZZ-AAAA-123456789012.
Required Endpoint key - provided by appsettings.json as settings.qna.endpointkey You shouldn't need to provide this value. QnA Maker portal's Settings for the knowledge base, after the knowledge base is published. For example, 12345678-AAAA-BBBB-CCCC-123456789012.
Required Hostname - provided by appsettings.json as settings.qna.hostname You shouldn't need to provide this value. QnA Maker portal's Settings for the knowledge base, after the knowledge base is published. For example, https://{qnamakername}.azurewebsites.net/qnamaker.
Optional Fallback answer This answer is specific to this bot and is not pulled for the QnA Maker service's match for no answer. For example, Answer not found in kb.
Required Threshold This answer is a floating point number such as 0.3 indicating 30% or better.
Optional Active learning card title Text to display to user before providing follow-up prompts, for example: Did you mean:.
Optional Card no match text Text to display as a card to the user at the end of the list of follow-up prompts to indicate none of the prompts match the user's need. For example: None of the above.
Optional Card no match response Text to display as a card to the user as a response to the user selecting the card indicating none of the follow-up prompts matched the user's need. For example: Thanks for the feedback.

Edit settings

To securely edit the QnA Maker settings, use the Advanced Settings View (json) view.

  1. Select Configure in the navigation pane. This provides the ability to edit the settings of your bot project.

  2. Now select Advanced Settings View (json) to edit the settings page in JSON format.

  3. Edit the values for the knowledgebaseid, qnaRegion, endpointKey, and the hostname. The endpoint key and host name are available from the QnA Maker portal's Publish page.

Tip

You can get these values from the QnA Maker service by selecting the View Code for the desired knowledge base while in the My knowledge bases view.

QnA Maker settings

Knowledge base limits

You can use Connect to a QnAKnowledgeBase Action to connect to only one knowledge base per dialog.

If your knowledge bases are domain agnostic and your scenario does not require you to keep them as separate knowledge bases, you can merge them to create one knowledge base and use Connect to QnAKnowledgeBase Action to build your dialog.

If your knowledge bases have content from different domains and your scenario requires you to connect multiple knowledge bases and show the single answer from the knowledge base with higher confidence score to the end user, use the Send an HTTP request Action to make two HTTP calls to two published knowledge bases, manipulate the response payload to compare the confidence scores and decide which answer should be shown to the end user.

Bots with Language Understanding (LUIS) and QnA Maker

Composer allows you to build bots that contain both QnA Maker and LUIS dialogs. A best practice is to set the confidence threshold for LUIS intent prediction and trigger QnA Maker through Intent event.