// Handles routing to additional dialogs logic. private async Task <DialogTurnResult> RouteStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var a = stepContext.Context.Activity; var state = await _stateAccessor.GetAsync(stepContext.Context, () => new AutomotiveSkillState(), cancellationToken); state.Clear(); if (a.Type == ActivityTypes.Message && !string.IsNullOrEmpty(a.Text)) { var skillResult = stepContext.Context.TurnState.Get <SettingsLuis>(StateProperties.SettingsLuisResultKey); var intent = skillResult?.TopIntent().intent; state.AddRecognizerResult(skillResult); // switch on general intents switch (intent) { case SettingsLuis.Intent.VEHICLE_SETTINGS_CHANGE: case SettingsLuis.Intent.VEHICLE_SETTINGS_DECLARATIVE: { return(await stepContext.BeginDialogAsync(nameof(VehicleSettingsDialog), cancellationToken : cancellationToken)); } case SettingsLuis.Intent.VEHICLE_SETTINGS_CHECK: { await stepContext.Context.SendActivityAsync(_templateManager.GenerateActivityForLocale(AutomotiveSkillMainResponses.FeatureNotAvailable), cancellationToken); break; } case SettingsLuis.Intent.None: { await stepContext.Context.SendActivityAsync(_templateManager.GenerateActivityForLocale(AutomotiveSkillSharedResponses.DidntUnderstandMessage), cancellationToken); break; } default: { await stepContext.Context.SendActivityAsync(_templateManager.GenerateActivityForLocale(AutomotiveSkillMainResponses.FeatureNotAvailable), cancellationToken); break; } } } else if (a.Type == ActivityTypes.Event) { // Handle skill actions here var eventActivity = a.AsEventActivity(); if (!string.IsNullOrEmpty(eventActivity.Name)) { switch (eventActivity.Name) { // Each Action in the Manifest will have an associated Name which will be on incoming Event activities case Events.ChangeVehicleSetting: { state.IsAction = true; SettingInfo actionData = null; var eventValue = a.Value as JObject; if (eventValue != null) { actionData = eventValue.ToObject <SettingInfo>(); actionData.DigestState(state); } return(await stepContext.BeginDialogAsync(nameof(VehicleSettingsDialog), cancellationToken : cancellationToken)); } default: { // todo: move the response to lg await stepContext.Context.SendActivityAsync(new Activity(type : ActivityTypes.Trace, text : $"Unknown Event '{eventActivity.Name ?? "undefined"}' was received but not processed."), cancellationToken); break; } } } } // If activity was unhandled, flow should continue to next step return(await stepContext.NextAsync(cancellationToken : cancellationToken)); }