// Runs when this dialog ends. Handles result of prompt to switch skills or resume waiting dialog. protected override async Task <DialogTurnResult> EndComponentAsync(DialogContext outerDc, object result, CancellationToken cancellationToken) { var skillId = await _skillIdAccessor.GetAsync(outerDc.Context, () => null).ConfigureAwait(false); var lastActivity = await _lastActivityAccessor.GetAsync(outerDc.Context, () => null).ConfigureAwait(false); outerDc.Context.Activity.Text = lastActivity.Text; // Ends this dialog. await outerDc.EndDialogAsync().ConfigureAwait(false); if ((bool)result) { // If user decided to switch, replace current skill dialog with new skill dialog. var skillDialogArgs = new SkillDialogArgs { SkillId = skillId }; // Start the skill dialog. return(await outerDc.ReplaceDialogAsync(skillId, skillDialogArgs).ConfigureAwait(false)); } else { // Otherwise, continue the waiting skill dialog with the user's previous utterance. return(await outerDc.ContinueDialogAsync().ConfigureAwait(false)); } }
private async Task <DialogTurnResult> RouteStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var activity = stepContext.Context.Activity.AsMessageActivity(); var userProfile = await _userProfileState.GetAsync(stepContext.Context, () => new UserProfileState()); if (!string.IsNullOrEmpty(activity.Text)) { // Get current cognitive models for the current locale. var localizedServices = _services.GetCognitiveModels(); // Get dispatch result from turn state. var dispatchResult = stepContext.Context.TurnState.Get <DispatchLuis>(StateProperties.DispatchResult); (var dispatchIntent, var dispatchScore) = dispatchResult.TopIntent(); if (IsSkillIntent(dispatchIntent)) { var dispatchIntentSkill = dispatchIntent.ToString(); var skillDialogArgs = new SkillDialogArgs { SkillId = dispatchIntentSkill }; // Start the skill dialog. return(await stepContext.BeginDialogAsync(dispatchIntentSkill, skillDialogArgs)); } else if (dispatchIntent == DispatchLuis.Intent.q_Faq) { stepContext.SuppressCompletionMessage(true); return(await stepContext.BeginDialogAsync("Faq")); } else if (dispatchIntent == DispatchLuis.Intent.q_Chitchat) { stepContext.SuppressCompletionMessage(true); return(await stepContext.BeginDialogAsync("Chitchat")); } else { stepContext.SuppressCompletionMessage(true); await stepContext.Context.SendActivityAsync("UNSUPPORTED"); return(await stepContext.NextAsync()); } } else { return(await stepContext.NextAsync()); } }
private async Task <DialogTurnResult> RouteStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Get dispatch result from turn state. var dispatchResult = stepContext.Context.TurnState.Get <DispatchLuis>(StateProperties.DispatchResult); (var dispatchIntent, var dispatchScore) = dispatchResult.TopIntent(); if (IsSkillIntent(dispatchIntent)) { var dispatchIntentSkill = dispatchIntent.ToString(); var skillDialogArgs = new SkillDialogArgs { SkillId = dispatchIntentSkill }; // Start the skill dialog. return(await stepContext.BeginDialogAsync(dispatchIntentSkill, skillDialogArgs)); } else if (dispatchIntent == DispatchLuis.Intent.q_Faq) { stepContext.SuppressCompletionMessage(true); return(await stepContext.BeginDialogAsync("Faq")); } else if (dispatchIntent == DispatchLuis.Intent.q_Chitchat) { stepContext.SuppressCompletionMessage(true); return(await stepContext.BeginDialogAsync("Chitchat")); } else { stepContext.SuppressCompletionMessage(true); await stepContext.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("UnsupportedMessage")); return(await stepContext.EndDialogAsync()); } }
private static void ApplyParentActivityProperties(ITurnContext turnContext, Activity skillActivity, SkillDialogArgs dialogArgs) { // Apply conversation reference and common properties from incoming activity before sending. skillActivity.ApplyConversationReference(turnContext.Activity.GetConversationReference(), true); skillActivity.ChannelData = turnContext.Activity.ChannelData; skillActivity.Properties = turnContext.Activity.Properties; if (dialogArgs != null) { skillActivity.Value = dialogArgs?.Value; } }