azurebotframeworkchatbotazure-qna-maker

How can I pre-filter answers from user input in QnA Maker?


I am currently developing a chatbot using QnA Maker. I am using the multi-turn feature by uploading an excel file with all the required questions, answers and other necessary details.

My premise is as follows:

I have a list of tools, their descriptions and in which category the tools fall into.

The bot is supposed to guide the user towards a tool according to the description they give.

The description of the tool are the questions and the tool name is the answer in the KB.

The tools are divided into different categories. For instance, say we have Category 1, Category 2 & Category 3 and Tool A, Tool B, Tool C & Tool D.

Category 1 contains Tool A & Tool C

Category 2 contains Tool B & Tool C

Category 3 contains Tool A, Tool C & Tool D

The user is first presented with a choice of categories in the form of buttons and I want to be able to pre filter the answers accordingly.

Therefore, if a user chooses Category 1, the bot is supposed to limit the search to only Tools A & C

Is there a way to achieve this in QnA Maker or maybe add the categories in the excel?

project_screenshot


Solution

  • Whenever you are passing category information into QnA maker you should add filter data ( Tool A ) as metadata. Check your automated code and verify while binding ( category buttons ) what kind of information is coming from QnA Maker. While clicking on these buttons you will get the category names, Pass them into one switch case and pick the right metadata name or Tool name for the further process. This metadata you can pass into the QnA Maker query as a filter.

    Example:

    {
    "question": "Category 1",
    "top": 3, // 3 top answers will get based on the threshold score.
    "isTest": true,
    "scoreThreshold": 30,
    "strictFilters": [
    {
        "name": "category1", 
        "value": "Tools A"
    }],
    

    }

    Reference:

    1. QnA Maker Docs