private async Task AskToStartLessonPlan(IDialogContext context) { var possibleResponses = new List <string>() { BotPersonality.GetStartLessonPlanQuestion(), BotPersonality.BotResponseToGibberish }; IReadOnlyCollection <string> translatedResponses; string language; if (context.UserData.TryGetValue(Constants.Shared.UserLanguageCodeKey, out language) && language != MessageTranslator.DEFAULT_LANGUAGE) { translatedResponses = await MessageTranslator.TranslateTextAsync(possibleResponses, language); } else { translatedResponses = possibleResponses; } PromptDialog.Confirm( context, TryStartLessonPlan, translatedResponses.ElementAtOrDefault(0) ?? string.Empty, translatedResponses.ElementAtOrDefault(1) ?? string.Empty); }
private void AskToStartLessonPlan(IDialogContext context) { PromptDialog.Confirm( context, TryStartLessonPlan, BotPersonality.GetStartLessonPlanQuestion(), BotPersonality.BotResponseToGibberish); }
private async Task EngageWithUser(IDialogContext context) { if (random.Next(2) == InitiateLessonPlan) { await AskToStartLessonPlan(context); } else { await context.PostTranslatedAsync(BotPersonality.BuildAcquaintance()); } }
public async Task HandleWhatIsIntent(IDialogContext context, LuisResult result) { if (result.Entities.Any(e => e.Type == BotEntities.Name)) { await context.PostAsync($"My name is {BotPersonality.BotName}"); } else { await context.PostAsync(BotPersonality.GetRandomGenericResponse()); } }
private async Task TryStartLessonPlan(IDialogContext context, IAwaitable <bool> result) { var confirm = await result; if (confirm) { LaunchLessonPlan(context); } else { await context.PostTranslatedAsync(BotPersonality.BotResponseToDeclinedLessonPlan); await context.PostTranslatedAsync(BotPersonality.BuildAcquaintance()); } }
public async Task HandleUserInformation(IDialogContext context, LuisResult result) { EntityRecommendation entity; string BotResponse = BotPersonality.GetRandomGenericResponse() + Shared.ClientNewLine; if (result.TryFindEntity(BotEntities.Name, out entity)) { ChatContext.Username = entity.Entity; BotResponse = BotPersonality.BotResponseToUserName + " " + ChatContext.Username + "! " + Shared.ClientNewLine; } else { BotResponse = BotPersonality.GetRandomGenericResponse(); } await context.PostTranslatedAsync(BotResponse); await EngageWithUser(context); }
public async Task HandleUserInformation(IDialogContext context, LuisResult result) { EntityRecommendation entity; string BotResponse = BotPersonality.GetRandomGenericResponse() + Shared.ClientNewLine; // var userData = _userDataRepository.GetUserData(context); if (result.TryFindEntity(BotEntities.Name, out entity)) { BotResponse = BotPersonality.BotSelfIntroduction + Shared.ClientNewLine; } else if (result.Entities.Any(e => e.Type == BotEntities.Hobby)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Animal)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Place)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Language)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Family)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Color)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Subject)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Food)) { } else if (result.Entities.Any(e => e.Type == BotEntities.Drink)) { } await context.PostTranslatedAsync(BotResponse); }
public async Task Greeting(IDialogContext context, LuisResult result) { if (result.Entities.Any(e => e.Type == BotEntities.StartConversation)) { string botresponse = BotPersonality.GetRandomGreeting(); await context.PostTranslatedAsync(botresponse); } else if (result.Entities.Any(e => e.Type == BotEntities.EndConversation)) { string botresponse = BotPersonality.GetRandomGoodbye(); await context.PostTranslatedAsync(botresponse); } else if (result.Entities.Any(e => e.Type == BotEntities.Name)) { var name = result.Entities.First(e => e.Type == BotEntities.Name); await context.PostTranslatedAsync($"Hello, {name?.Entity}. Nice to meet you!"); } else { await context.PostTranslatedAsync("Hello..."); } }
public async Task HandleWhatIsIntent(IDialogContext context, LuisResult result) { if (result.Entities.Any(e => e.Type.Equals(BotEntities.Name, System.StringComparison.CurrentCultureIgnoreCase))) { await context.PostTranslatedAsync($"My name is {BotPersonality.BotName}"); } else if (result.Entities.Any(e => e.Type.Equals(BotEntities.encyclopediaOrganization, System.StringComparison.CurrentCultureIgnoreCase))) { await context.PostTranslatedAsync($"I think it is a company..."); } else if (result.Entities.Any(e => e.Type.Equals(BotEntities.Color, System.StringComparison.CurrentCultureIgnoreCase))) { await context.PostTranslatedAsync($"My favorite color is blue. Blue is the color of light between violet and green on the visible spectrum... It is chosen by almost half of both men and women as their favourite colour."); } else if (result.Entities.Any(e => e.Type.Equals(BotEntities.Time, System.StringComparison.CurrentCultureIgnoreCase))) { await context.PostTranslatedAsync($"Right now is {DateTime.Now.ToShortTimeString()} at Seattle, WA"); } else if (result.Entities.Any(e => e.Type.Equals(BotEntities.Date, System.StringComparison.CurrentCultureIgnoreCase))) { var date = DateTime.Now.ToLongDateString(); await context.PostTranslatedAsync($"Oh yeah, let me check my digital calendar. Today is... {date}"); } else if (result.Entities.Any(e => e.Type.Equals(BotEntities.PlaceLive, System.StringComparison.CurrentCultureIgnoreCase))) { await context.PostTranslatedAsync($"Well, I live on DTML.org website. Please visit me sometime."); } else { await context.PostTranslatedAsync(BotPersonality.GetRandomGenericResponse()); } }
public async Task Courtesy(IDialogContext context, LuisResult result) { await context.PostTranslatedAsync(BotPersonality.GetRandomGenericResponse()); await EngageWithUser(context); }
public async Task Greeting(IDialogContext context, LuisResult result) { string botresponse = BotPersonality.GetRandomGreeting(); await context.PostTranslatedAsync(botresponse); }
public async Task HandleIAmIntent(IDialogContext context, LuisResult result) { await context.PostAsync(BotPersonality.GetRandomGenericResponse()); }
public async Task HandleLearnEnglishIntent(IDialogContext context, LuisResult result) { string botresponse = BotPersonality.GetRandomStartLesson(); await context.PostAsync(botresponse); }