private async Task <DialogTurnResult> ShowTeamsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var tokenResponse = (TokenResponse)stepContext.Result; if (tokenResponse?.Token == null) { await stepContext.Context.SendActivityAsync(MessageFactory.Text("Login was not successful please try again."), cancellationToken); return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken)); } var service = new TeamsService(tokenResponse.Token); var teams = await service.GetJoinedTeamsAsync(); if (teams.Length == 0) { await stepContext.Context.SendActivityAsync("Sorry, you do not belong to any team at the moment."); return(await stepContext.EndDialogAsync(null, cancellationToken)); } else if (teams.Length == 1) { var team = teams.First(); var userProfile = await UserProfileAccessor.GetAsync(stepContext.Context); userProfile.SelectedTeam = team; await stepContext.Context.SendActivityAsync($"You only have one team: {team.DisplayName}. It was selected automatically."); return(await stepContext.EndDialogAsync(team, cancellationToken)); } else { stepContext.Values["teams"] = teams; var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("Please select one of you teams:"), Choices = teams.Select(i => new Choice(i.DisplayName)).ToArray(), Style = ListStyle.HeroCard }; return(await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions, cancellationToken)); } }