private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = await _luisRecognizer.RecognizeAsync <IdeasModel>(stepContext.Context, cancellationToken); switch (luisResult.TopIntent().intent) { case IdeasModel.Intent.Idea_Create: return(await stepContext.BeginDialogAsync(nameof(CreateIdeaDialog), new CreateIdeaOptions(), cancellationToken)); case IdeasModel.Intent.Idea_List: return(await stepContext.BeginDialogAsync(nameof(ListIdeasDialog), new ListIdeasOptions(), cancellationToken)); case IdeasModel.Intent.Team_Switch: return(await stepContext.BeginDialogAsync(nameof(SelectTeamDialog), cancellationToken : cancellationToken)); case IdeasModel.Intent.Data_Clear: var botAdapter = (BotFrameworkAdapter)stepContext.Context.Adapter; await botAdapter.SignOutUserAsync(stepContext.Context, ConnectionName, null, cancellationToken); await UserState.ClearStateAsync(stepContext.Context, cancellationToken); await stepContext.Context.SendActivityAsync("User data and security token were cleared."); return(await stepContext.NextAsync(null, cancellationToken)); case IdeasModel.Intent.None: break; } return(await stepContext.NextAsync(null, cancellationToken)); }
public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken = default) { if (turnContext == null) { throw new ArgumentNullException(nameof(turnContext)); } if (turnContext.Activity.Type == ActivityTypes.Message) { if (_resetPhrases.Contains(turnContext.Activity.Text?.ToLowerInvariant())) { await _conversationState.ClearStateAsync(turnContext); await _userState.ClearStateAsync(turnContext); await _conversationState.SaveChangesAsync(turnContext, false, cancellationToken); await _userState.SaveChangesAsync(turnContext, false, cancellationToken); await turnContext.SendActivityAsync(MessageFactory.Text(MiddlewareStrings.Reset, MiddlewareStrings.ResetSpeak), cancellationToken); return; } } await next(cancellationToken).ConfigureAwait(false); }