问题
I am trying to call QnA Maker on a waterfall dialog step.
How do I call it from this watterfall
step, do I need to set up QnA On the waterfall step, do I need to call QnA from a LUIS intent, what can I do?
I need it to get the first result from the QnA using the step context from the previous question.
Can anyone help?
Code:
private async Task<DialogTurnResult> QnaAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var response = await qnaMaker.GetAnswersAsync(stepContext);
// use answer found in qnaResults[0].answer
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(response[0].Answer)}, cancellationToken);
}
回答1:
It looks like you don't have qnaMaker
defined in your code above, there. You can really call QnAMaker from anywhere, so long as you have a QnAMaker service defined somewhere.
I recommend following this sample. It's fairly complex, but is the best example of using QnAMaker within a Waterfall Dialog.
I'll point out some pieces that you will find most useful:
- Create the QnAMaker service
- Use dependency injection so that you can access the BotServices from anywhere in the project
- Add the services to the dialog's constructor
- Call the QnAMaker service
Again, that sample is fairly complex. If you need additional pointers, please update your question with the code that you've tried and I'll see if I can help.
来源:https://stackoverflow.com/questions/59181187/how-to-call-qna-maker-on-a-waterfall-dialog-using-c