You can specify a minimum confidence score via the scoreThreshold
option in a QnAMakerOption
.
See the botbuilder-js repo for what options are available in QnAMakerOptions
, including scoreThreshold.
Now where you could actually pass in the QnAMakerOptions
, to ensure your answers have at least 60% confidence, you have a couple of options:
- In the constructor of creating a new
QnAMaker
instance:
const endpoint = {
knowledgeBaseId: process.env.QnAKnowledgebaseId,
endpointKey: process.env.QnAEndpointKey,
host: process.env.QnAEndpointHostName
};
const options = { scoreThreshold: .6 };
const qna = new QnAMaker(endpoint, options);
- Pass in
QnAMakerOptions
when you call QnAMaker.getAnswers()
method:
const qna = new QnAMaker(endpoint);
const options = { scoreThreshold: .6 }
const qnaResults = await qna.getAnswers(context, options);
See sample 11.qnamaker in the official BotBuilder-Samples repo for basics on how to set up a QnA Maker bot. To deploy local changes to Azure (if you have the bot locally and aren't just using the online web editor to update your bot), follow Deploy your bot docs.
In the sample it just returns "No QnA Maker answers were found" if no QnA Maker answers were found within the scoreThreshold, but you could easily change this to instead send your desired default answer.