Add a QnA Maker knowledge base to your bot

APPLIES TO: Composer v1.x and v2.x

Note

Azure QnA Maker will be retired on 31 March 2025. Beginning 1 October 2022, you won't be able to create new QnA Maker resources or knowledge bases. A newer version of the question and answering capability is now available as part of Azure AI Language.

Custom question answering, a feature of Azure AI Language, is the updated version of the QnA Maker service. For more information about question-and-answer support in Composer, see Natural language processing.

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'll 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 doesn't allow any authoring or two-way connectivity, it's a simple way to query QnA from a dialog. Also, it doesn't 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, 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're 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 isn't 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 doesn't require you to keep them as separate knowledge bases, you can merge them to create one knowledge base, and then 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

Note

Language Understanding (LUIS) will be retired on 1 October 2025. Beginning 1 April 2023, you won't be able to create new LUIS resources. A newer version of language understanding is now available as part of Azure AI Language.

Conversational language understanding (CLU), a feature of Azure AI Language, is the updated version of LUIS. For more information about question-and-answer support in Composer, see Natural language processing.

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.