I was thinking as bots have some generic questions like how are you ? may be i have around 10 answers which i would like Q&A maker to choose randomly not every time same answer.
or also questions like tell me a story
QnA Maker provides a conversational question and answer layer over your data. This allows your bot to send a question to the QnA Maker and receive an answer without needing to parse and interpret the question intent.
QnA Maker uses the trained knowledge base to provide the correct answer and any follow-up prompts that can be used to refine the search for the best answer. QnA Maker returns a JSON-formatted response. The client application uses the JSON response to make decisions about how to continue the conversation.
QnAs in the form of structured . txt, . tsv or . xls files can also be uploaded to QnA Maker to create or augment a knowledge base.
some generic questions like how are you ? may be i have around 10 answers which i would like Q&A maker to choose randomly not every time same answer.
To achieve this requirement, you can try this approach:
1) Add a QnA pair and use a special character (such as |
) to split answers for question how are you?
2) Override the RespondFromQnAMakerResultAsync
method, and split response and retrieve answer randomly in this method
protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
{
// This will only be called if Answers isn't empty
var response = result.Answers.First().Answer;
var answersforhowareyou = response.Split('|');
if (answersforhowareyou.Count() > 1)
{
Random rnd = new Random();
int index = rnd.Next(answersforhowareyou.Count());
response = answersforhowareyou[index];
}
await context.PostAsync(response);
}
Test result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With