【发布时间】:2020-02-27 18:53:04
【问题描述】:
我正在使用示例 Azure MSGraph Bot 身份验证 (https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Dialogs/MainDialog.cs#L112),没有任何代码更改(仅更改 APP id 和连接名称)。这是代码的一部分,对我来说是错误的:
private async Task<DialogTurnResult> ProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
if (stepContext.Result != null)
{
var tokenResponse = stepContext.Result as TokenResponse;
if (tokenResponse?.Token != null)
{
var parts = ((string)stepContext.Values["command"] ?? string.Empty).ToLowerInvariant().Split(' ');
var command = parts[0];
if (command == "me")
{
await OAuthHelpers.ListMeAsync(stepContext.Context, tokenResponse);
}
else if (command.StartsWith("send"))
{
await OAuthHelpers.SendMailAsync(stepContext.Context, tokenResponse, parts[1]);
}
else if (command.StartsWith("recent"))
{
await OAuthHelpers.ListRecentMailAsync(stepContext.Context, tokenResponse);
}
else
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Your token is: {tokenResponse.Token}"), cancellationToken);
}
}
}
else
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("We couldn't log you in. Please try again later."), cancellationToken);
}
return await stepContext.EndDialogAsync(cancellationToken: cancellationToken);
}
当我输入“我”命令时,接收我的凭据。之后,我输入了另一个命令(例如,“recent”),机器人再次欢迎我。我认为这可能是因为 ProcessStepAsync 方法只调用一次,然后对话框返回到第一步。但我希望机器人每次收到我的命令时都返回到 if/else 对话框。
换句话说,当我输入命令时,我怎样才能改变对话的轮次,所以它会再次回到 ProcessStepAsync?
【问题讨论】:
-
问题解决了吗?让我知道你的更新。
-
好的,我会在尝试解决方案后立即通知您,谢谢
-
听起来不错,编码时间很长???
标签: c# azure botframework