public async Task StartAsync(IDialogContext context)
        {
            try
            {
                FacetResult facetResult = await searchService.FetchFacets();

                if (facetResult.searchfacets.Era.Length != 0)
                {
                    List <string> eras = new List <string>();
                    foreach (Era era in facetResult.searchfacets.Era)
                    {
                        eras.Add($"{era.value} ({era.count})");
                    }
                    PromptDialog.Choice(context, AfterMenuSelection, eras, "Which era of music are you interested in?");
                }
                else
                {
                    await context.PostAsync("I couldn't find any genres to show you");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when faceting by era: {e}");
                context.Done <object>(null);
            }
        }
        public async Task ExploreCategory(IDialogContext context, LuisResult result)
        {
            EntityRecommendation categoryEntityRecommendation;

            result.TryFindEntity("category", out categoryEntityRecommendation);
            var category =
                ((Newtonsoft.Json.Linq.JArray)categoryEntityRecommendation?
                 .Resolution["values"])?[0]?.ToString();
            var originalText = result.Query;

            AzureSearchService searchService = new AzureSearchService();

            if (string.IsNullOrWhiteSpace(category))
            {
                FacetResult facetResult = await searchService.FetchFacets();

                if (facetResult.Facets.Category.Length != 0)
                {
                    List <string> categories = new List <string>();
                    foreach (Category searchedCategory in facetResult.Facets.Category)
                    {
                        categories.Add($"{searchedCategory.Value}({ searchedCategory.Count})");
                    }

                    PromptDialog.Choice(context, this.AfterMenuSelection, categories,
                                        "お探しの答えがKBの中にあるか確認しましょう。" +
                                        "どのカテゴリーをご覧になりますか?");
                }
            }
            else
            {
                SearchResult searchResult
                    = await searchService.SearchByCategory(category);

                if (searchResult.Value.Length != 0)
                {
                    await context.PostAsync($"{category} には以下のようなKBが" +
                                            "見つかりました。" +
                                            "**More details** をクリックすると詳細が表示されます。");
                }

                await CardUtil.ShowSearchResults(context, searchResult,
                                                 $"KBから{category} カテゴリーの記事は見つかりませんでした。");

                context.Done <object>(null);
            }
        }
Exemple #3
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = context.Activity.AsMessageActivity();

            FacetResult facetResult = await searchService.FetchFacets();

            if (facetResult.searchfacets.Category.Length != 0)
            {
                var categories = (
                    from item in facetResult.searchfacets.Category
                    select item.value)
                                 .ToList();

                PromptDialog.Choice(context, OnCategoryOptionSelected, categories, $"The Cognitive Services are divided into five main categories. Which category are you interested in finding out more about?", "Sorry, thats not a valid option", 3);
            }

            else
            {
                context.Done("Oops! Something went wrong!");
            }
        }