/// <summary> /// Find an appropriate intent handler and use it to process the incoming intent. /// </summary> /// <param name="request"></param> /// <param name="lambdaContext"></param> /// <returns></returns> public override SkillResponse HandleRequest(SkillRequest request, ILambdaContext lambdaContext) { IntentRequest intentRequest = request.Request as IntentRequest; lambdaContext.Logger.LogLine("Request Intent: " + intentRequest.Intent.Name); IntentHandler handler = CustomIntentHandlers.Find(x => x.IsHandlerForIntent(intentRequest.Intent)); if (handler != null) { // Custom handler return(handler.HandleIntent(intentRequest.Intent, request.Session, lambdaContext)); } else if (SupportedIntents.Contains(intentRequest.Intent.Name)) { // Otherwise we have a story intent return(Story.CreateResponse(intentRequest.Intent, request.Session, lambdaContext)); } else { // Otherwise we have no way of dealing with this intent lambdaContext.Logger.LogLine("No intent handler found"); return(ResponseBuilder.Empty()); } }
/// <summary> /// Handles the intent logic. /// </summary> /// <param name="intent">The LuisResult containing the detected intent.</param> /// <returns>A list of actions for Robbie to execute, based on the provided intent.</returns> private async Task <IList <IAction> > HandleIntent(LuisResult intent) { // todo: UpdateEmotions shouldn't always happen. Preferably move to Intent.HandleIntent or in it's actionclass if (!currentIdentityPersonId.Equals(AnonymousPersonId)) { await UpdateEmotion(); var experienceProfile = await GetClientForCurrentUser().GetExperienceProfile(); if (experienceProfile.OnsiteBehavior.ActiveProfiles?.Length > 0 && experienceProfile.OnsiteBehavior.ActiveProfiles[0].PatternMatches?.Length > 0) { // todo: log profile card to events, just debugging purposes var patternName = experienceProfile.OnsiteBehavior.ActiveProfiles?[0].PatternMatches?[0].PatternName; var matchPercentage = experienceProfile.OnsiteBehavior.ActiveProfiles?[0].PatternMatches?[0].MatchPercentage; ReportEvent("behaviour", $"{patternName} {matchPercentage}"); // todo: get profile, just for debugging purposes // ReSharper disable once UnusedVariable var profile = await GetClientForCurrentUser().GetProfile(); } } // create intent handler after intent has been returned and retrieve all actions that are tied to this intent var handler = new IntentHandler(intent, GetClientForCurrentUser()); var actions = await handler.HandleIntent(); return(actions); }