How to call QnA Maker on a waterfall dialog using C#?

倾然丶 夕夏残阳落幕 提交于 2021-01-27 11:14:55

问题


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?

Code

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:

  1. Create the QnAMaker service
  2. Use dependency injection so that you can access the BotServices from anywhere in the project
  3. Add the services to the dialog's constructor
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!