I'm using sample Azure MSGraph Bot Authentication (https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Dialogs/MainDialog.cs#L112), without any code changes (only changing APP id's and connection name). Here is the part of code, that works for me wrong:
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);
}
When I'm typing "me" command, receive my credentials. After that I'm typing another command (for example, "recent"), and bot welcomes me again. I think this can be because of ProcessStepAsync method calls only once, and then dialog returns to first step. But I want bot to return to if/else dialog every time it receives command from me.
In other words, how can I change turn of dialog, so it will back to ProcessStepAsync again, when i'm typing command?