【发布时间】:2019-03-16 07:58:03
【问题描述】:
我有一个瀑布对话框,提示用户选择“是”或“否”。用户选择“是”后,机器人不会继续下一个瀑布对话框。
第一个瀑布步骤。
private static async Task<DialogTurnResult> LoginStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
{
var tokenResponse = (TokenResponse)step.Result;
if (tokenResponse != null)
{
await step.Context.SendActivityAsync("You are now logged in.", cancellationToken: cancellationToken);
return await step.PromptAsync(
ConfirmPromptName,
new PromptOptions
{
Prompt = MessageFactory.Text($"Would you like to view your token? {tokenResponse.Token}"),
Choices = new List<Choice> { new Choice("Yes"), new Choice("No") },
},
cancellationToken);
}
await step.Context.SendActivityAsync("Login was not successful please try again.", cancellationToken: cancellationToken);
return Dialog.EndOfTurn;
}
第二个瀑布步骤。
private static async Task<DialogTurnResult> DisplayTokenAsync(WaterfallStepContext step, CancellationToken cancellationToken)
{
var result = (bool)step.Result;
if (result)
{
var prompt = await step.BeginDialogAsync(LoginPromptName, cancellationToken: cancellationToken);
var tokenResponse = (TokenResponse)prompt.Result;
if (tokenResponse != null)
{
await step.Context.SendActivityAsync($"Here is your token {tokenResponse.Token}", cancellationToken: cancellationToken);
}
}
return Dialog.EndOfTurn;
}
我在这里缺少什么?先感谢您。我关注了this 指南和this 项目。
编辑:我在机器人的构造函数中设置了对话框,将提示和瀑布对话框添加到集合中。
var waterfallSteps = new WaterfallStep[]
{
PromptStepAsync,
LoginStepAsync,
DisplayTokenAsync,
};
_dialogs.Add(new WaterfallDialog("authDialog", waterfallSteps));
【问题讨论】:
标签: c# authentication botframework