예제 #1
0
        private async Task OptionSelected(IDialogContext context, IAwaitable <string> result)

        {
            try

            {
                string optionSelected = await result;
                RootDialog.UserResponse = optionSelected.ToString();


                switch (optionSelected)

                {
                case ConfirmOption:

                    context.Call(new ConfirmDialog(), this.ResumeAfterOptionDialog);

                    break;

                case RejectOption:

                    context.Call(new RejectDialog(), this.ResumeAfterOptionDialog);

                    break;
                }
            }

            catch (Exception e)

            {
                SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());

                //await context.PostAsync("enter a valid option");
            }
        }
예제 #2
0
 private async Task SendMail(IDialogContext context, IAwaitable <object> result)
 {
     try
     {
         using (MailMessage mailmsg = new MailMessage("*****@*****.**", "*****@*****.**"))
         {
             mailmsg.Subject    = "Visitor Badge request";
             mailmsg.Body       = $"Your visitor badge request has been raised and the reference number is {VisitorID}";
             mailmsg.IsBodyHtml = false;
             SmtpClient smtp = new SmtpClient();
             smtp.Host      = "smtp.office365.com";
             smtp.EnableSsl = true;
             NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "Intelligence@");
             smtp.UseDefaultCredentials = true;
             smtp.Credentials           = NetworkCred;
             smtp.Port = 587;
             smtp.Send(mailmsg);
         }
         this.StartAsync(context);
     }
     catch (Exception e)
     {
         SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
     }
 }
예제 #3
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;
          }
      }
예제 #4
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");
                }
            }
        }
예제 #5
0
      public async Task NoOfParkingTickets(IDialogContext context, IAwaitable <object> result)
      {
          try
          {
              var activity = await result as Activity;
              int tickets  = Convert.ToInt16(activity.Text);
              VisitorData.NoOfParkingTicket = tickets;
              RootDialog.UserResponse       = activity.Text;
              RootDialog.BotResponse        = SQLManager.GetVisitorBadgeQuestions(16);
              await context.PostAsync(RootDialog.BotResponse);

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

              this.SelectBuilding(context, result);
          }
          catch (Exception e)
          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //throw e;
          }
      }
예제 #6
0
      public async Task MoreVisitors(IDialogContext context, IAwaitable <string> result)
      {
          try

          {
              string optionSelected = await result;
              RootDialog.UserResponse = optionSelected;
              //RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(21);


              switch (optionSelected)

              {
              case AddOption:
                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                  context.Wait(VistorName);

                  break;

              case RemoveOption:
                  RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(22);
                  SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse);
                  await context.PostAsync(RootDialog.BotResponse);

                  context.Wait(EnterAnyComments);


                  //context.Call(new RejectDialog(), this.ResumeAfterOptionDialog);

                  break;
              }
          }

          catch (Exception e)

          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              // await context.PostAsync("enter a valid option");
          }
      }
예제 #7
0
      public async Task OptionSelected(IDialogContext context, IAwaitable <string> result)
      {
          try

          {
              string optionSelected = await result;
              //RootDialog.UserResponse = optionSelected;
              //VisitorData.NeedParking = Convert.ToBoolean(optionSelected);
              switch (optionSelected)

              {
              case YesOption:
                  VisitorData.NeedParking = true;
                  RootDialog.UserResponse = VisitorData.NeedParking.ToString();
                  RootDialog.BotResponse  = SQLManager.GetVisitorBadgeQuestions(15);
                  await context.PostAsync(RootDialog.BotResponse);

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

                  context.Wait(NoOfParkingTickets);

                  break;

              case NoOption:
                  VisitorData.NeedParking = false;
                  RootDialog.UserResponse = VisitorData.NeedParking.ToString();
                  this.SelectBuilding(context, result);
                  //context.Call(new RejectDialog(), this.ResumeAfterOptionDialog);

                  break;
              }
          }

          catch (Exception e)

          {
              SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
              //await context.PostAsync("enter a valid option");
          }
      }
예제 #8
0
        public async Task RaiseIssue(IDialogContext context, IAwaitable <string> result)
        {
            RootDialog root = new RootDialog();

            try

            {
                string optionSelected = await result;
                RootDialog.UserResponse = optionSelected;
                switch (optionSelected)

                {
                case "Yes":
                    RootDialog.BotResponse = SQLManager.GetITQuestions(5);
                    await context.PostAsync(RootDialog.BotResponse);

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


                    break;

                case "No":
                    root.StartAsync(context);

                    break;
                }
            }

            catch (Exception e)

            {
                SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString());
                // await context.PostAsync("enter a valid option");
            }
        }
예제 #9
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");
                }
            }
        }
예제 #10
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");
                }
            }
        }