我有两个瀑布对话框,步骤如下:
主对话框
private async Task<DialogTurnResult> LoginStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
return await stepContext.BeginDialogAsync(nameof(LoginDialog), cancellationToken: cancellationToken);
}
private async Task<DialogTurnResult> IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
return await stepContext.BeginDialogAsync(nameof(QnADialog), stepContext.Options, cancellationToken);
}
private async Task<DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
return await stepContext.EndDialogAsync(null, cancellationToken);
}
QnA对话框
private async Task<DialogTurnResult> WelcomeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
Options = (QnADialogOptions)stepContext.Options;
if (Options.IsProactive)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("What I want to happend when I send a proactive message"), cancellationToken);
return await stepContext.PromptAsync($"{nameof(QnADialog)}.addAnswer"),
new PromptOptions
{
Prompt = MessageFactory.Text("Do you want to add the answer for the question?"),
Choices = ChoiceFactory.ToChoices(new List<string> { "Yes", "No" })
}, cancellationToken);
}
else
{
return await stepContext.PromptAsync($"{nameof(QnADialog)}.welcome",
new PromptOptions
{
}, cancellationToken);
}
}
private async Task<DialogTurnResult> QnAStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
if (Options.IsProactive)
{
if (stepContext.Result.Equals("Yes"))
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("test"), cancellationToken);
return await stepContext.EndDialogAsync($"{nameof(QnADialog)}.mainFlow");
}
else
{
return await stepContext.EndDialogAsync($"{nameof(QnADialog)}.mainFlow");
}
}
else
{
//search and display the answer
}
}
private async Task<DialogTurnResult> AddAnswerStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
//if no answer was found, send proactive message to another user
}
这是主动回调:
private async Task BotCallback(ITurnContext turnContext, CancellationToken cancellationToken)
{
await turnContext.SendActivityAsync(message);
var dialog = new DialogSet(_stateService.DialogStateAccessor);
dialog.Add(new MainDialog(_logger,_stateService,_botServices,_configuration,_conversationReferences));
var dc = await dialog.CreateContextAsync(turnContext);
await dc.BeginDialogAsync(nameof(MainDialog), new QnADialogOptions(default, message, true),cancellationToken);
}
我向用户发送主动消息,我想检索他们的答案。但是在我要求用户提示他是否要添加答案后,对话就结束了。这是一个屏幕截图。 我希望我的对话框等待输入,然后转到下一个瀑布步骤。我怎样才能做到这一点?