public async Task MovieSearch(IDialogContext context, LuisResult result_luis)
        {
            QureyController qc  = new QureyController();
            string          ans = "";

            qc.PostQuestionOne(result_luis.Query, result_luis.TopScoringIntent.Intent, result_luis.TopScoringIntent.Score.ToString(), "0");
            if (result_luis.TopScoringIntent.Score < 0.4)
            {
                ans = qc.GetTrainedAnswer(result_luis.Query);
                qc.PostAnswerOne(ans, result_luis.TopScoringIntent.Intent);
                await context.PostAsync(ans);

                context.Wait(MessageReceived);
            }
            else
            {
                string entity = "";

                if (result_luis.Entities.Count > 0)
                {
                    entity = result_luis.Entities[0].Entity;
                }

                if (entity == "")
                {
                    entity = "Star Wars: The Last Jedi";
                    await context.PostAsync("Here is a movie which i found : ");
                }
                try
                {
                    MoviesSearch search      = new MoviesSearch();
                    Movie        movieResult = await search.SearchByName(entity);

                    if (movieResult.id != 0)
                    {
                        CardUtil.showHeroCard((IMessageActivity)context.Activity, movieResult);
                        ans = movieResult.Title;
                    }
                    else
                    {
                        await context.PostAsync($"I couldn't find a movie :0");
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"Error when filtering by genre: {e}");
                }

                qc.PostAnswerOne(ans, result_luis.TopScoringIntent.Intent);
                context.Done <object>(null);
            }
        }
Exemple #2
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            string entity = "";

            if (message.Text.Length > 0)
            {
                entity = message.Text;
            }

            await context.PostAsync("Here is a movie which i found : ");

            if (entity == "")
            {
                entity = "Star Wars: The Last Jedi";
            }
            try
            {
                MoviesSearch search      = new MoviesSearch();
                Movie        movieResult = await search.SearchByName(entity);

                if (movieResult.id != 0)
                {
                    CardUtil.showHeroCard((IMessageActivity)context.Activity, movieResult);
                }
                else
                {
                    await context.PostAsync($"I couldn't find a movie :/");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when filtering by genre: {e}");
            }

            context.Done(this);
        }
        public virtual async Task MessageRecievedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            try
            {
                SearchResult searchResult = await searchService.SearchByName(message.Text);

                if (searchResult.value.Length != 0)
                {
                    CardUtil.showHeroCard(message, searchResult);
                }
                else
                {
                    await context.PostAsync($"No musicians by the name {message.Text} found");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when searching for musician: {e.Message}");
            }
            context.Done <object>(null);
        }
Exemple #4
0
        private async Task AfterMenuSelection(IDialogContext context, IAwaitable <string> result)
        {
            var    optionSelected = await result;
            string selectedEra    = optionSelected.Split(' ')[0];

            try
            {
                SearchResult searchResult = await searchService.SearchByEra(selectedEra);

                if (searchResult.value.Length != 0)
                {
                    CardUtil.showHeroCard((IMessageActivity)context.Activity, searchResult);
                }
                else
                {
                    await context.PostAsync($"I couldn't find any musicians in that era :0");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when filtering by genre: {e}");
            }
            context.Done <object>(null);
        }