コード例 #1
0
        public async Task NoneIntent(IDialogContext context, LuisResult result)
        {
            SetKeywords(result.Query);
            if (!keywords.Any())
            {
                await context.PostAsync("Sorry couldn't understand that. Could you repeat it?");
            }
            else
            {
                MessagesController.ReqJson input = new MessagesController.ReqJson();


                input.image         = this.image;
                input.keywords      = keywords;
                input.maxoutputsize = 3;


                string request = JsonConvert.SerializeObject(input);


                string respJS = await GetResponseAsync(request, context);


                MessagesController.RespJson respObj = JsonConvert.DeserializeObject <MessagesController.RespJson>(respJS);


                await context.PostAsync($"These are top {respObj.hotels.GetLength(0)} suitable hotels for you:");

                foreach (MessagesController.Hotel h in respObj.hotels)
                {
                    await WriteHotelEntry(h, context);
                }
                if (!arrDateGiven)
                {
                    await context.PostAsync("When do you want to begin your trip?");
                }
                else if (!depDateGiven)
                {
                    await context.PostAsync("When do you want to end your trip?");
                }
                else
                {
                    await context.PostAsync("If you want to change the start date of your trip just enter the new one." +
                                            "Additionally you can search for another trip with an image or information.");
                }

                context.Wait(MessageReceived);
            }
        }
コード例 #2
0
        public async Task Dategiving(IDialogContext context, LuisResult result)
        {
            EntityRecommendation dateEntityRecommendation;

            if (result.TryFindEntity(date, out dateEntityRecommendation))
            {
                if (!arrDateGiven)
                {
                    arrivalDate  = dateEntityRecommendation.Entity;
                    arrDateGiven = true;
                    await context.PostAsync("When do you want to end your trip?");
                }
                else
                {
                    if (!depDateGiven)
                    {
                        if (!keywords.Any() && image == "")
                        {
                            await context.PostAsync("Please describe your dream trip or load an image of it.");
                        }
                        else
                        {
                            departureDate = dateEntityRecommendation.Entity;
                            depDateGiven  = true;
                            MessagesController.ReqJson input = new MessagesController.ReqJson();
                            input.image         = this.image;
                            input.arrivalDate   = arrivalDate;
                            input.departureDate = departureDate;
                            input.keywords      = keywords;
                            input.maxoutputsize = 5;
                            string request = JsonConvert.SerializeObject(input);
                            string respJS  = await GetResponseAsync(request, context);

                            MessagesController.RespJson respObj = JsonConvert.DeserializeObject <MessagesController.RespJson>(respJS);
                            await context.PostAsync($"These are top {respObj.hotels.GetLength(0)} suitable hotels for you:");

                            foreach (MessagesController.Hotel h in respObj.hotels)
                            {
                                await WriteHotelEntry(h, context);
                            }
                            await context.PostAsync("If you want to change the start date of your trip just enter the new one." +
                                                    "Additionally you can search for another trip with an image or information.");

                            context.Wait(MessageReceived);
                        }
                    }
                    else
                    {
                        depDateGiven  = false;
                        arrivalDate   = dateEntityRecommendation.Entity;
                        departureDate = "";
                        await context.PostAsync("When do you want to end your trip?");
                    }
                }
            }
            else
            {
                await context.PostAsync("Sorry couldn't understand that. Could you repeat it?");
            }
            context.Wait(MessageReceived);
        }