Ejemplo n.º 1
0
        private async Task StaticQuestion(IDialogContext context, IAwaitable <object> result)
        {
            var    option = await result as Activity;
            string choice = option.Text;
            string Response;

            UserResponse = 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(choice));

                    Data = JsonConvert.DeserializeObject <LuisResponse>(responseInString);

                    choice = null;
                    var    intent     = Data.topScoringIntent.intent;
                    string IntentName = intent;
                    var    score      = Data.topScoringIntent.score;
                    Data.entities.OrderBy(o => o.startIndex);
                    if (score > 0.8)
                    {
                        switch (IntentName)
                        {
                        case "FAQHrtAtkDefine":
                            Response = SQLManager.GetResponse(IntentName);
                            await context.PostAsync($"{Response}");

                            break;

                        case "FAQHrtAtkSymptoms":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "FAQHrtAtkMeasures":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "FAQHrtAtkCardiacArrest":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "FAQHrtAtkPrecaution":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "FinanceGlobalCorporateCardApply":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "FinanceOut-of-PocketExpensesClaim":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "EnterpriseCodeofConductFind":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "ITHelpdeskSupport":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        case "None":
                            Response = SQLManager.GetResponse(IntentName);

                            await context.PostAsync($"{Response}");

                            break;

                        default:
                            await this.DynamicQuestion(context, result);

                            break;
                        }
                    }
                    else
                    {
                        await context.PostAsync("Sorry we couldn't found it");

                        await context.PostAsync("can you please mention the main topic of question?");
                    }
                }
                catch (Exception e)
                {
                    SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
                    //await context.PostAsync("StaticException");
                }
            }
        }