/// <summary> /// Method called after the user has chosen their preferred bot persona. /// </summary> /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param> /// <param name="result">Mandatory. The users chosen preferred bot persona. </param> private async Task ResumeAfterPromptDialogChoice(IDialogContext context, IAwaitable <PersonalityChatPersona> result) { PersonalityChatPersona chosenPersona = await result; _botDataService.SetPreferredBotPersona(context, chosenPersona); context.Done(chosenPersona.ToString()); }
public PersonalityChatDialogOptions(string subscriptionKey = "", PersonalityChatPersona botPersona = PersonalityChatPersona.Friendly, bool respondOnlyIfChat = false, float scenarioThresholdScore = 0.3F, Dictionary <string, List <string> > scenarioResponsesMapping = null) : base(subscriptionKey, botPersona, scenarioResponsesMapping) { this.RespondOnlyIfChat = respondOnlyIfChat; this.ScenarioThresholdScore = scenarioThresholdScore; }
public PersonalityChoiceHeroCard(PersonalityChatPersona personalityType, string title, string subtitle, string imageUrl) { PersonalityType = personalityType; Title = title; Subtitle = subtitle; ImageUrl = imageUrl; }
public PersonalityChatMiddlewareOptions(string subscriptionKey = "", PersonalityChatPersona botPersona = PersonalityChatPersona.Friendly, bool respondOnlyIfChat = true, float scoreThreshold = 0.3F, bool endActivityRoutingOnResponse = true, Dictionary<string, List<string>> scenarioResponsesMapping = null) : base(subscriptionKey, botPersona, scenarioResponsesMapping) { this.RespondOnlyIfChat = respondOnlyIfChat; this.ScoreThreshold = scoreThreshold; this.EndActivityRoutingOnResponse = endActivityRoutingOnResponse; }
public BotPersonaDialog(IBotDataService botDataService, IList <EntityRecommendation> entities, PersonalityChatPersona preferredBotPersona, IMessageHelper messageHelpers) { SetField.NotNull(out _botDataService, nameof(botDataService), botDataService); SetField.NotNull(out _messageHelper, nameof(messageHelpers), messageHelpers); _entities = entities; _preferredBotPersona = preferredBotPersona; }
/// <summary> /// Method called after the user has chosen which persona they'd like buddy to use. /// </summary> /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param> /// <param name="result">Mandatory. The user's preferred bot persona specified from the <see cref="PersonalityChoiceHeroCard"/>.</param> private async Task Resume_AfterBotPersonaChoice(IDialogContext context, IAwaitable <IMessageActivity> result) { var activity = await result; PersonalityChatPersona personaChoice = (PersonalityChatPersona)Enum.Parse(typeof(PersonalityChatPersona), activity.Text); context.Call(_dialogBuilder.BuildBotPersonaDialog(context.Activity.AsMessageActivity(), null, personaChoice), Resume_AfterBotPersonaDialog); await Task.CompletedTask; }
/// <summary> /// Sets the users preferred bot personality to BotData. /// </summary> /// <param name="botData">Mandatory. User's private bot data.</param> /// <param name="persona">Mandatory. The bot personality to set as the users /// preferred bot personality</param> public void SetPreferredBotPersona(IBotData botData, PersonalityChatPersona persona) { botData.SetValue(DataStoreKey.PreferredBotPersona, persona); }
public BotPersonaDialog BuildBotPersonaDialog(IMessageActivity message, PersonalityChatPersona result) { return(CreateDialog(message, s => s.Resolve <BotPersonaDialog>(TypedParameter.From(result)))); }
public BotPersonaDialog BuildBotPersonaDialog(IMessageActivity message, IList <EntityRecommendation> result, PersonalityChatPersona persona) { return(CreateDialog(message, s => s.Resolve <BotPersonaDialog>(TypedParameter.From(result), TypedParameter.From(persona)))); }
/// <summary> /// Execution for the <see cref="BotPersonaDialog"/> starts here. /// </summary> /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param> public Task StartAsync(IDialogContext context) { /** * ---------------------------------------------------- * Order of Dialog Flow: * ---------------------------------------------------- * * - Check if there is hero card selection, if yes, * confirm and finish. * * - Check if dialog has entities, extract, confirm and * finish. * * - Check if user has pre-saved persona, prompt to * update, if yes,prompt options, confirm and finish. * * - Else, prompt user for option, confirm and finish. **/ // Check if there is hero card selection if (_preferredBotPersona != PersonalityChatPersona.None) { PromptDialog.Confirm(context, ResumeAfterConfirmChosenPersona, $"So you'd like to set my personality as {_preferredBotPersona}?", $"Sorry I don't understand - try again! Should I set my personality to {_preferredBotPersona}?"); return(Task.CompletedTask); } // Else we can assume LUIS called the dialog else { if (_entities.Count > 0 || _entities != null) { Enum.TryParse(_messageHelper.ExtractEntityFromMessage("User.PreferredBotPersona", _entities), out PersonalityChatPersona parsedResult); _preferredBotPersona = parsedResult; } } // Check If LUIS found entity preference, otherwise continue if (_preferredBotPersona != PersonalityChatPersona.None) { PromptDialog.Confirm(context, ResumeAfterConfirmChosenPersona, $"So you'd like me to change my personality to {_preferredBotPersona}?", $"Sorry I don't understand - try again! Should I change my personality to {_preferredBotPersona}?"); return(Task.CompletedTask); } PersonalityChatPersona preSavedPersona = _botDataService.GetPreferredBotPersona(context); // Check if user has pre-saved persona, otherwise continue if (preSavedPersona != PersonalityChatPersona.None) { PromptDialog.Confirm(context, ResumeAfterUpdateConfirmation, $"My persona is set to {preSavedPersona}. Would you like to change it?", $"Sorry I don't understand - try again! Would you like to change my persona?"); return(Task.CompletedTask); } // Could not determine preferred personality prompt user to choose PromptDialog.Choice(context, ResumeAfterPromptDialogChoice, Enum.GetValues(typeof(PersonalityChatPersona)) .Cast <PersonalityChatPersona>() .Where(p => p != PersonalityChatPersona.None), "What would you like my personality to be?"); return(Task.CompletedTask); }
/// <summary> /// Constructs the PersonalityChat request. /// </summary> public PersonalityChatRequest(string query, PersonalityChatPersona botPersona) { this.Query = query; this.Persona = botPersona; }
/// <summary> /// Constructs the PersonalityChatOptions using the options. /// </summary> public PersonalityChatOptions(string subscriptionKey = "", PersonalityChatPersona botPersona = PersonalityChatPersona.Friendly, Dictionary <string, List <string> > scenarioResponse = null) { this.SubscriptionKey = subscriptionKey; this.BotPersona = botPersona; this.scenarioResponse = scenarioResponse; }