예제 #1
0
        public override async Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            if (ConversationData.WaitingForUserInput)
            {
                var userInput = ConversationUtils.GetUserReply(turnContext);
                if (DialogUtils.IsUserInputInOptions(userInput, Constants.UserIntentSelection.ReservationPossibleSelectionValues))
                {
                    ConversationData.CurrentConversationIntent = BotSupportedIntents.MaintenanceBookingService;
                }
                else if (DialogUtils.IsUserInputInOptions(userInput, Constants.UserIntentSelection.CheckingStatusPossibleSelectionValues))
                {
                    ConversationData.CurrentConversationIntent = BotSupportedIntents.GettingUpdatesAboutCurrentRequests;
                }
                else
                {
                    await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                        Constants.General.InvalidValueProvided,
                        this.UserProfile,
                        turnContext,
                        cancellationToken);
                }

                if (ConversationData.CurrentConversationIntent.HasValue)
                {
                    ConversationData.SetWaitingForUserInputFlag(false);
                }
            }
        }
예제 #2
0
        public override async Task StartAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Constants.RequestedMaintenanceServiceSelection.AskingForRequiredService,
                UserProfile,
                turnContext,
                cancellationToken);

            ConversationData.SetWaitingForUserInputFlag();
        }
        public override async Task StartAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            await Utilities.ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Dialogs.Constants.ServiceFieldsMessages.ServiceDeliveryTimeMessage,
                UserProfile,
                turnContext,
                cancellationToken);

            ConversationData.SetWaitingForUserInputFlag();
        }
예제 #4
0
        public override async Task StartAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            await Utilities.ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Constants.UserIntentSelection.IntentSelection,
                UserProfile,
                turnContext,
                cancellationToken);

            ConversationData.SetWaitingForUserInputFlag();
        }
        public override async Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var      userInput         = Utilities.ConversationUtils.GetUserReply(turnContext);
            DateTime?userRequestedDate = null;

            if (Utilities.DialogUtils.IsUserInputInOptions(userInput, Dialogs.Constants.ServiceFieldsMessages.TodayOptionValues))
            {
                userRequestedDate = DateTime.Now;
            }
            else if (Utilities.DialogUtils.IsUserInputInOptions(userInput, Dialogs.Constants.ServiceFieldsMessages.TomorrowOptionValues))
            {
                userRequestedDate = DateTime.Now.AddDays(1);
            }
            else if (!Utilities.DialogUtils.TryGetDateFromUserInput(userInput, out userRequestedDate))
            {
                ConversationData.ServiceBookingForm.FailedToRecognizeProvidedDate = true;
            }

            if (userRequestedDate.HasValue)
            {
                if (userRequestedDate < DateTime.Now.Date)
                {
                    await Utilities.ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                        Dialogs.Constants.ServiceFieldsMessages.DateInThePastErrorMessage,
                        UserProfile,
                        turnContext,
                        cancellationToken);
                }
                else
                {
                    ConversationData.ServiceBookingForm.FailedToRecognizeProvidedDate = true;
                    ConversationData.SetWaitingForUserInputFlag(false);
                    ConversationData.ServiceBookingForm.Day   = userRequestedDate.Value.Day;
                    ConversationData.ServiceBookingForm.Month = userRequestedDate.Value.Month;
                    ConversationData.ServiceBookingForm.Year  = userRequestedDate.Value.Year;
                }
            }
            else
            {
                await Utilities.ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                    Dialogs.Constants.General.InvalidValueProvided,
                    UserProfile,
                    turnContext,
                    cancellationToken);

                ConversationData.SetWaitingForUserInputFlag(false);
            }
        }
예제 #6
0
        public override async Task StartAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            await ConversationUtils.SendMessage(
                string.Format(Constants.General.Greetings.CombineLanguageValues(), this.UserProfile.Name),
                turnContext,
                cancellationToken
                );

            await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Constants.LanguageSelection.AskingForpreferredLanguage,
                this.UserProfile,
                turnContext,
                cancellationToken);

            ConversationData.SetWaitingForUserInputFlag();
        }
        public override async Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var      userInput         = Utilities.ConversationUtils.GetUserReply(turnContext);
            TimeSpan?userRequestedTime = null;

            if (Utilities.DialogUtils.IsUserInputInOptions(userInput, Dialogs.Constants.ServiceFieldsMessages.AsSoonAsPossibleOptionValues))
            {
                var todayDateAndTime = DateTime.Now;
                if (ConversationData.ServiceBookingForm.Year > todayDateAndTime.Year ||
                    ConversationData.ServiceBookingForm.Month > todayDateAndTime.Month ||
                    ConversationData.ServiceBookingForm.Day > todayDateAndTime.Day)
                {
                    userRequestedTime = new TimeSpan(8, 0, 0);
                }
                else
                {
                    userRequestedTime = todayDateAndTime.AddHours(1).TimeOfDay;
                    if (userRequestedTime.Value.Hours < todayDateAndTime.Hour)
                    {
                        userRequestedTime = new TimeSpan(23, 59, 59);
                    }
                }
            }
            else if (!Utilities.DialogUtils.TryGetTimeFromUserInput(userInput, out userRequestedTime))
            {
                ConversationData.ServiceBookingForm.FailedToRecognizeProvidedTime = true;
                await Utilities.ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                    Dialogs.Constants.General.InvalidValueProvided,
                    UserProfile,
                    turnContext,
                    cancellationToken);

                this.ConversationData.SetWaitingForUserInputFlag(false);
            }

            if (userRequestedTime.HasValue)
            {
                ConversationData.ServiceBookingForm.FailedToRecognizeProvidedTime = true;
                ConversationData.SetWaitingForUserInputFlag(false);
                ConversationData.ServiceBookingForm.Hour       = userRequestedTime.Value.Hours % 12;
                ConversationData.ServiceBookingForm.Minutes    = userRequestedTime.Value.Minutes;
                ConversationData.ServiceBookingForm.DayOrNight = userRequestedTime.Value.Hours > 12 ? "PM" : "AM";
            }
        }
예제 #8
0
        public override async Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var userInput = ConversationUtils.GetUserReply(turnContext);

            if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.CarpentryPossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.Carpentry;
            }
            else if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.ElectricalMaintenancePossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.ElectricalMaintenance;
            }
            else if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.PlumbingPossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.PlumbingServices;
            }
            else if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.AirConditioningPossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.AirConditioningMaintenance;
            }
            else if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.PaintingPossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.PaintingServices;
            }
            else if (DialogUtils.IsUserInputInOptions(userInput, Constants.RequestedMaintenanceServiceSelection.CleaningPossibleValues))
            {
                ConversationData.ServiceBookingForm.RequestedService = SupportedMaintenanceServices.Cleaning;
            }
            else
            {
                await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                    Constants.General.InvalidValueProvided,
                    UserProfile,
                    turnContext,
                    cancellationToken
                    );
            }

            if (ConversationData.ServiceBookingForm.RequestedService.HasValue)
            {
                ConversationData.SetWaitingForUserInputFlag(false);
            }
        }
        public override async Task ProActiveMessageToUseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var messageFormattingValues = new string[]
            {
                this.ConversationData.NewUserMaintenanceServiceId,
                this.ConversationData.ServiceBookingForm.RequiredServiceDescription
            };

            await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Constants.RequestStatusUpdate.ServiceRequestDeliveredMessage,
                UserProfile,
                turnContext,
                cancellationToken,
                formattingValues : new MessageOption()
            {
                Arabic  = messageFormattingValues,
                English = messageFormattingValues
            });

            ConversationData.SetWaitingForUserInputFlag();
        }
        public override async Task StartAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var formRepresentation = new string[]
            {
                this.ConversationData.ServiceBookingForm.ToLocalizedStrings(this.UserProfile.PreferredLanguage.Value)
            };

            var formValuesStringRepresentation = new MessageOption()
            {
                English = formRepresentation,
                Arabic  = formRepresentation
            };

            await ConversationUtils.SendMessageBasedOnUserPreferredLanguage(
                Constants.Confirmation.ConfirmationMessage,
                this.UserProfile,
                turnContext,
                cancellationToken,
                formattingValues : formValuesStringRepresentation);

            ConversationData.SetWaitingForUserInputFlag(true);
        }
 public override Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
 {
     ConversationData.ServiceBookingForm.RequiredServiceDescription = ConversationUtils.GetUserReply(turnContext);
     ConversationData.SetWaitingForUserInputFlag(false);
     return(Task.FromResult(0));
 }