protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) { var state = await _stateAccessor.GetAsync(dc.Context, () => new EmailSkillState()); // get current activity locale var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; var localeConfig = _skillConfig.LocaleConfigurations[locale]; // If dispatch result is general luis model localeConfig.LuisServices.TryGetValue("email", out var luisService); if (luisService == null) { throw new Exception("The specified LUIS Model could not be found in your Bot Services configuration."); } else { var result = await luisService.RecognizeAsync <Email>(dc.Context, CancellationToken.None); var intent = result?.TopIntent().intent; var generalTopIntent = state.GeneralLuisResult?.TopIntent().intent; var skillOptions = new EmailSkillDialogOptions { SkillMode = _skillMode, SubFlowMode = false }; // switch on general intents switch (intent) { case Email.Intent.SendEmail: { await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions); break; } case Email.Intent.Forward: { await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions); break; } case Email.Intent.Reply: { await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions); break; } case Email.Intent.SearchMessages: case Email.Intent.CheckMessages: case Email.Intent.ReadAloud: case Email.Intent.QueryLastText: { await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions); break; } case Email.Intent.Delete: { await dc.BeginDialogAsync(nameof(DeleteEmailDialog), skillOptions); break; } case Email.Intent.None: { if (generalTopIntent == General.Intent.Next || generalTopIntent == General.Intent.Previous) { await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions); } else { await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(EmailSharedResponses.DidntUnderstandMessage)); if (_skillMode) { await CompleteAsync(dc); } } break; } default: { await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(EmailMainResponses.FeatureNotAvailable)); if (_skillMode) { await CompleteAsync(dc); } break; } } } }
protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) { var state = await _stateAccessor.GetAsync(dc.Context, () => new EmailSkillState()); // If dispatch result is general luis model _services.LuisServices.TryGetValue("email", out var luisService); if (luisService == null) { throw new Exception("The specified LUIS Model could not be found in your Bot Services configuration."); } else { var result = await luisService.RecognizeAsync <Email>(dc.Context, CancellationToken.None); var intent = result?.TopIntent().intent; var skillOptions = new EmailSkillDialogOptions { SkillMode = _skillMode, }; // switch on general intents switch (intent) { case Email.Intent.SendEmail: { await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions); break; } case Email.Intent.Forward: { await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions); break; } case Email.Intent.Reply: { await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions); break; } case Email.Intent.SearchMessages: case Email.Intent.CheckMessages: { await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions); break; } case Email.Intent.None: { await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(EmailSharedResponses.DidntUnderstandMessage)); if (_skillMode) { await CompleteAsync(dc); } break; } default: { await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(EmailMainResponses.FeatureNotAvailable)); if (_skillMode) { await CompleteAsync(dc); } break; } } } }