private async Task <DialogTurnResult> ProcessStep2Async(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var tokenResponse = (TokenResponse)stepContext.Result; if (tokenResponse != null) { // We do not need to store the token in the bot. When we need the token we can // send another prompt. If the token is valid the user will not need to log back in. // The token will be available in the Result property of the task. // If we have the token use the user is authenticated so we may use it to make API calls. 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)); }