Azure QnA Bot Knowledge base filter using metadata

Viewed 23

I've created a bot after publishing the Azure QnA service knowledge base. I've added the metadata to each question answer pairs to denote the source of information. Now, I want to change the bot code to limit the knowledge base search using the metadata filter. Basically, Bot would initially prompt users to input source (for eg HR, Finance, Legal) and use that input further to only search through question answers pairs tagged to it.

bot source code that is used -> https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/48.customQABot-all-features

How can I change this code to return answers linked to specified metadata/user input dynamically?

please note README.md does provide information about how to filter answers by passing metadata but it has used static value ({ key: 'Language', value: 'Javascript' }).

I want to pass user input from CustomQABot.js to rootDialog.js so that it will be used in rootDialog.js to filter answers.

any input would be greatly appreciated. Thanks.

ps - I don't know much about node.js so it's very hard for me to understand the program flow.

1 Answers

Here's some documentation that explains how MSFT Bot Framework bots work.

Essentially, the bot invokes dialogs based on the user's input. Each dialog contains some form of conversation on a specific topic. Once a dialog is complete it exits and the user can ask for a new dialog, or just leave.

For example, a travel booking bot may have multiple dialogs, one for each activity. They might have one for booking airlines, one for cruise lines, and one for long distance buses, plus another for modifying or cancelling tickets.

In the example bot you have, there is just one dialog called rootDialog. You could start by trying to modify this dialog to ask the user what filter they wish to use and use that for the rest of the dialog. The user would be asked this question every time the dialog starts.

I'd highly recommend you read through some of the documentation and play with some of the other samples to understand how bots work first.

Related