Beispiel #1
0
      public async Task EnterContactName(IDialogContext context, IAwaitable <object> result)
      {
          var    activity    = await result as Activity;
          string contactname = activity.Text;

          try

          {
              using (HttpClient httpClient = new HttpClient())
              {
                  LuisResponse Data = new LuisResponse();

                  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(contactname));

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



                  var    intent     = Data.topScoringIntent.intent;
                  string IntentName = intent;
                  var    score      = Data.topScoringIntent.score;

                  if (IntentName == "VisitorNameIntent" && score > 0.8)

                  {
                      contactname             = Data.entities[0].entity.ToString();
                      RootDialog.UserResponse = contactname;
                      VisitorData.ContactName = contactname.ToString();
                      RootDialog.BotResponse  = SQLManager.GetVisitorBadgeQuestions(8);
                      await context.PostAsync(RootDialog.BotResponse);

                      SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);


                      this.GetStartDate(context, result);
                  }


                  else

                  {
                      await context.PostAsync("please enter the  valid contact name");

                      context.Wait(EnterDepartment);
                  }
              }
          }


          catch (Exception e)
          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //throw e;
          }
      }
Beispiel #2
0
        public async Task EnterEmail(IDialogContext context, IAwaitable <object> result)
        {
            var    message = await result as Activity;
            string UserID  = message.Text;

            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(UserID));

                    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);
                    //string UserName;

                    if (IntentName == "UserInfo" && score > 0.8)
                    {
                        UserData.UserID = Data.entities[0].entity.ToString();

                        UserData.UserName = SQLManager.GetName(UserData.UserID);

                        if (UserData.UserName.Equals(""))

                        {
                            await context.PostAsync("Enter a valid email");
                        }
                        else
                        {
                            await context.PostAsync($"hi {UserData.UserName},How can I help you?");

                            context.Wait(StaticQuestion);
                        }
                    }
                    else
                    {
                        await context.PostAsync("UserName not found");
                    }
                }
                catch (Exception e)
                {
                    SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
                    //await context.PostAsync("Name Exception");
                }
            }
        }
Beispiel #3
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var    message = await result as Activity;
            string issue   = message.Text;

            RootDialog.UserResponse = issue;

            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(issue));

                    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);
                    //string UserName;

                    if (IntentName == "RaiseITTicket" && score > 0.8)
                    {
                        await IssueCategory(context, result);
                    }
                    else
                    {
                        await context.PostAsync("invalid question which is not related");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
Beispiel #4
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");
                }
            }
        }
Beispiel #5
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");
                }
            }
        }