Example #1
0
        private async Task DynamicQuestion(IDialogContext context, IAwaitable <object> result)
        {
            var    option  = await result as Activity;
            string choice2 = option.Text;
            string Response;

            //string choice2 = choice;
            using (HttpClient httpClient = new HttpClient())
            {
                LuisResponse Data = new LuisResponse();
                try
                {
                    var responseInString = await httpClient.GetStringAsync(@"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/daac86e9-b94a-4897-9f5e-3dea98dc3cde?staging=true&verbose=true&timezoneOffset=-360&subscription-key=60c884e98ad84389b452b71ed84894b4&q="
                                                                           + System.Uri.EscapeDataString(choice2));

                    Data = JsonConvert.DeserializeObject <LuisResponse>(responseInString);
                    var    intent     = Data.topScoringIntent.intent;
                    string IntentName = intent;
                    var    score      = Data.topScoringIntent.score;
                    Data.entities.OrderBy(o => o.startIndex);



                    switch (IntentName)
                    {
                    case "RealEstateMeetingRoomReservationBook":
                        Response = SQLManager.GetDynamicResponse(IntentName);
                        await context.PostAsync($" {Response}");


                        break;

                    case "RealEstateReceptionRegister":
                        Response = SQLManager.GetDynamicResponse(IntentName);
                        await context.PostAsync($" {Response}");

                        break;

                    case "RealEstateShuttleBusSchedule":

                        Response = SQLManager.GetDynamicResponse(IntentName);
                        await context.PostAsync($" {Response}");

                        break;

                    case "TravelBookITBook":

                        Response = SQLManager.GetDynamicResponse(IntentName);
                        await context.PostAsync($" {Response}");

                        break;

                    case "VisitorIntent":
                        vreg.StartAsync(context);

                        break;

                    default:
                        //vreg.StartAsync(context);
                        IT.StartAsync(context);
                        break;
                    }
                }

                catch (Exception e)
                {
                    SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
                    //throw e;
                    //await context.PostAsync("Dynamic Exception");
                }
            }
        }