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);
        }
Exemplo n.º 2
0
 private void AskToStartLessonPlan(IDialogContext context)
 {
     PromptDialog.Confirm(
         context,
         TryStartLessonPlan,
         BotPersonality.GetStartLessonPlanQuestion(),
         BotPersonality.BotResponseToGibberish);
 }
Exemplo n.º 3
0
 private async Task EngageWithUser(IDialogContext context)
 {
     if (random.Next(2) == InitiateLessonPlan)
     {
         await AskToStartLessonPlan(context);
     }
     else
     {
         await context.PostTranslatedAsync(BotPersonality.BuildAcquaintance());
     }
 }
Exemplo n.º 4
0
 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());
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 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...");
     }
 }
Exemplo n.º 9
0
 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());
     }
 }
Exemplo n.º 10
0
        public async Task Courtesy(IDialogContext context, LuisResult result)
        {
            await context.PostTranslatedAsync(BotPersonality.GetRandomGenericResponse());

            await EngageWithUser(context);
        }
Exemplo n.º 11
0
 public async Task Greeting(IDialogContext context, LuisResult result)
 {
     string botresponse = BotPersonality.GetRandomGreeting();
     await context.PostTranslatedAsync(botresponse);
 }
Exemplo n.º 12
0
 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);
 }