예제 #1
0
        public RestaurantBooking(
            SkillConfigurationBase services,
            EndpointService endpointService,
            ConversationState conversationState,
            UserState userState,
            ProactiveState proactiveState,
            IBotTelemetryClient telemetryClient,
            IBackgroundTaskQueue backgroundTaskQueue,
            bool skillMode = false,
            ResponseManager responseManager  = null,
            IServiceManager serviceManager   = null,
            IHttpContextAccessor httpContext = null)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _serviceManager    = serviceManager ?? new ServiceManager();
            _httpContext       = httpContext;

            if (responseManager == null)
            {
                responseManager = new ResponseManager(
                    _services.LocaleConfigurations.Keys.ToArray(),
                    new RestaurantBookingSharedResponses(),
                    new RestaurantBookingMainResponses());
            }

            _responseManager = responseManager;
            _dialogs         = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _httpContext, _skillMode));
        }
예제 #2
0
        public override void Initialize()
        {
            var builder = new ContainerBuilder();

            this.ConversationState  = new ConversationState(new MemoryStorage());
            this.UserState          = new UserState(new MemoryStorage());
            this.TelemetryClient    = new NullBotTelemetryClient();
            this.EmailStateAccessor = this.ConversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState));
            this.Services           = new MockSkillConfiguration();

            builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState));
            var fakeServiceManager = new MockServiceManager();

            builder.RegisterInstance <IServiceManager>(fakeServiceManager);

            this.Container      = builder.Build();
            this.ServiceManager = fakeServiceManager;

            ResponseManager = new ResponseManager(
                responseTemplates: new IResponseIdCollection[]
            {
                new FindContactResponses(),
                new DeleteEmailResponses(),
                new ForwardEmailResponses(),
                new EmailMainResponses(),
                new ReplyEmailResponses(),
                new SendEmailResponses(),
                new EmailSharedResponses(),
                new ShowEmailResponses(),
            },
                locales: new string[] { "en", "de", "es", "fr", "it", "zh" });

            ConfigData.GetInstance().MaxDisplaySize = 3;
            ConfigData.GetInstance().MaxReadSize    = 3;
        }
예제 #3
0
        public SkillTemplateDialog(
            string dialogId,
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <SkillConversationState> conversationStateAccessor,
            IStatePropertyAccessor <SkillUserState> userStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(dialogId)
        {
            Services                  = services;
            ResponseManager           = responseManager;
            ConversationStateAccessor = conversationStateAccessor;
            UserStateAccessor         = userStateAccessor;
            ServiceManager            = serviceManager;
            TelemetryClient           = telemetryClient;

            // NOTE: Uncomment the following if your skill requires authentication
            //if (!Services.AuthenticationConnections.Any())
            //{
            //    throw new Exception("You must configure an authentication connection in your bot file before using this component.");
            //}

            //AddDialog(new EventPrompt(DialogIds.SkillModeAuth, "tokens/response", TokenResponseValidator));
            //AddDialog(new MultiProviderAuthDialog(services));
        }
예제 #4
0
        public PointOfInterestSkillDialog(
            string dialogId,
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(dialogId)
        {
            Services        = services;
            ResponseManager = responseManager;
            Accessor        = accessor;
            ServiceManager  = serviceManager;
            TelemetryClient = telemetryClient;
            _httpContext    = httpContext;

            AddDialog(new TextPrompt(Actions.CurrentLocationPrompt));
            AddDialog(new TextPrompt(Actions.Prompt));
            AddDialog(new ConfirmPrompt(Actions.ConfirmPrompt)
            {
                Style = ListStyle.Auto,
            });
            AddDialog(new ChoicePrompt(Actions.SelectPointOfInterestPrompt)
            {
                Style = ListStyle.Auto, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
        }
예제 #5
0
파일: MainDialog.cs 프로젝트: scovetta/AI
        public MainDialog(
            SkillConfigurationBase services,
            EndpointService endpointService,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            ProactiveState proactiveState,
            IBotTelemetryClient telemetryClient,
            IBackgroundTaskQueue backgroundTaskQueue,
            IServiceManager serviceManager,
            bool skillMode)
            : base(nameof(MainDialog), telemetryClient)
        {
            _skillMode           = skillMode;
            _services            = services;
            _endpointService     = endpointService;
            _responseManager     = responseManager;
            _userState           = userState;
            _conversationState   = conversationState;
            _proactiveState      = proactiveState;
            TelemetryClient      = telemetryClient;
            _backgroundTaskQueue = backgroundTaskQueue;
            _serviceManager      = serviceManager;

            // Initialize state accessor
            _stateAccessor          = _conversationState.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState));
            _proactiveStateAccessor = _proactiveState.CreateProperty <ProactiveModel>(nameof(ProactiveModel));

            // Register dialogs
            RegisterDialogs();
        }
        public ToDoSkillDialog(
            string dialogId,
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <ToDoSkillState> toDoStateAccessor,
            IStatePropertyAccessor <ToDoSkillUserState> userStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(dialogId)
        {
            Services          = services;
            ResponseManager   = responseManager;
            ToDoStateAccessor = toDoStateAccessor;
            UserStateAccessor = userStateAccessor;
            ServiceManager    = serviceManager;
            TelemetryClient   = telemetryClient;

            if (!Services.AuthenticationConnections.Any())
            {
                throw new Exception("You must configure an authentication connection in your bot file before using this component.");
            }

            AddDialog(new EventPrompt(SkillModeAuth, "tokens/response", TokenResponseValidator));
            AddDialog(new MultiProviderAuthDialog(services));
            AddDialog(new TextPrompt(Action.Prompt));
            AddDialog(new ConfirmPrompt(Action.ConfirmPrompt, null, Culture.English)
            {
                Style = ListStyle.SuggestedAction
            });
        }
예제 #7
0
        public SummaryDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(SummaryDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var initStep = new WaterfallStep[]
            {
                Init,
            };

            var showNext = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ShowNextEvent,
            };

            var showSummary = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ShowEventsSummary,
                CallReadEventDialog,
                AskForShowOverview,
                AfterAskForShowOverview
            };

            var readEvent = new WaterfallStep[]
            {
                ReadEvent,
                AfterReadOutEvent,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.GetEventsInit, initStep)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.ShowNextEvent, showNext)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.ShowEventsSummary, showSummary)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Read, readEvent)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new UpdateEventDialog(services, accessor, serviceManager, telemetryClient));
            AddDialog(new ChangeEventStatusDialog(services, accessor, serviceManager, telemetryClient));

            // Set starting dialog for component
            InitialDialogId = Actions.GetEventsInit;
        }
예제 #8
0
        public ConnectToMeetingDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(ConnectToMeetingDialog), services, responseManager, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var joinMeeting = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                JoinMeeting
            };

            AddDialog(new WaterfallDialog(Actions.ConnectToMeeting, joinMeeting)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Actions.ConnectToMeeting;
        }
예제 #9
0
        public FindPointOfInterestDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor<PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(FindPointOfInterestDialog), services, responseManager, accessor, serviceManager, telemetryClient, httpContext)
        {
            TelemetryClient = telemetryClient;

            var checkCurrentLocation = new WaterfallStep[]
            {
                CheckForCurrentCoordinatesBeforeFindPointOfInterest,
                ConfirmCurrentLocation,
                ProcessCurrentLocationSelection,
                RouteToFindPointOfInterestDialog
            };

            var findPointOfInterest = new WaterfallStep[]
            {
                GetPointOfInterestLocations,
                ProcessPointOfInterestSelection,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.CheckForCurrentLocation, checkCurrentLocation) { TelemetryClient = telemetryClient });
            AddDialog(new WaterfallDialog(Actions.FindPointOfInterest, findPointOfInterest) { TelemetryClient = telemetryClient });
            AddDialog(new RouteDialog(services, responseManager, Accessor, ServiceManager, TelemetryClient, httpContext));

            // Set starting dialog for component
            InitialDialogId = Actions.CheckForCurrentLocation;
        }
예제 #10
0
        public UpcomingEventDialog(
            SkillConfigurationBase services,
            EndpointService endpointService,
            ResponseManager responseManager,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IStatePropertyAccessor <ProactiveModel> proactiveStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IBackgroundTaskQueue backgroundTaskQueue)
            : base(nameof(UpcomingEventDialog), services, responseManager, accessor, serviceManager, telemetryClient)
        {
            _backgroundTaskQueue    = backgroundTaskQueue;
            _proactiveStateAccessor = proactiveStateAccessor;
            _endpointService        = endpointService;
            _responseManager        = responseManager;

            var upcomingMeeting = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                QueueUpcomingEventWorker
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.ShowUpcomingMeeting, upcomingMeeting));

            // Set starting dialog for component
            InitialDialogId = Actions.ShowUpcomingMeeting;
        }
예제 #11
0
        public MainDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            IBotTelemetryClient telemetryClient,
            IServiceManager serviceManager,
            bool skillMode)
            : base(nameof(MainDialog), telemetryClient)
        {
            _skillMode         = skillMode;
            _services          = services;
            _responseManager   = responseManager;
            _conversationState = conversationState;
            _userState         = userState;
            _serviceManager    = serviceManager;
            TelemetryClient    = telemetryClient;

            // Initialize state accessor
            _conversationStateAccessor = _conversationState.CreateProperty <SkillConversationState>(nameof(SkillConversationState));
            _userStateAccessor         = _userState.CreateProperty <SkillUserState>(nameof(SkillUserState));

            // RegisterDialogs
            RegisterDialogs();
        }
예제 #12
0
        public PointOfInterestSkill(
            SkillConfigurationBase services,
            ConversationState conversationState,
            UserState userState,
            IBotTelemetryClient telemetryClient,
            bool skillMode = false,
            ResponseManager responseManager = null,
            IServiceManager serviceManager  = null)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _serviceManager    = serviceManager ?? new ServiceManager();
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            if (responseManager == null)
            {
                var supportedLanguages = services.LocaleConfigurations.Keys.ToArray();
                responseManager = new ResponseManager(
                    new IResponseIdCollection[]
                {
                    new CancelRouteResponses(),
                    new FindPointOfInterestResponses(),
                    new POIMainResponses(),
                    new RouteResponses(),
                    new POISharedResponses(),
                }, supportedLanguages);
            }

            _responseManager = responseManager;
            _dialogs         = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
예제 #13
0
        public CancelRouteDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(CancelRouteDialog), services, responseManager, accessor, serviceManager, telemetryClient, httpContext)
        {
            TelemetryClient = telemetryClient;

            var cancelRoute = new WaterfallStep[]
            {
                CancelActiveRoute,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.CancelActiveRoute, cancelRoute)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Actions.CancelActiveRoute;
        }
예제 #14
0
        public ConfirmRecipientDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <EmailSkillState> emailStateAccessor,
            IStatePropertyAccessor <DialogState> dialogStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(ConfirmRecipientDialog), services, emailStateAccessor, dialogStateAccessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var confirmRecipient = new WaterfallStep[]
            {
                ConfirmRecipient,
                AfterConfirmRecipient,
            };

            var updateRecipientName = new WaterfallStep[]
            {
                UpdateUserName,
                AfterUpdateUserName,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.ConfirmRecipient, confirmRecipient)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.UpdateRecipientName, updateRecipientName)
            {
                TelemetryClient = telemetryClient
            });
            InitialDialogId = Actions.ConfirmRecipient;
        }
예제 #15
0
        public MainDialog(
            SkillConfigurationBase skillConfiguration,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            IBotTelemetryClient telemetryClient,
            IServiceManager serviceManager,
            bool skillMode)
            : base(nameof(MainDialog), telemetryClient)
        {
            _skillMode         = skillMode;
            _skillConfig       = skillConfiguration;
            _responseManager   = responseManager;
            _conversationState = conversationState;
            _userState         = userState;
            TelemetryClient    = telemetryClient;
            _serviceManager    = serviceManager;

            // Initialize state accessor
            _stateAccessor       = _conversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState));
            _dialogStateAccessor = _conversationState.CreateProperty <DialogState>(nameof(DialogState));

            RegisterDialogs();
            GetReadingDisplayConfig();
        }
예제 #16
0
        public FindPointOfInterestDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(FindPointOfInterestDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var findPointOfInterest = new WaterfallStep[]
            {
                GetPointOfInterestLocations,
                ResponseToGetRoutePrompt,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Action.FindPointOfInterest, findPointOfInterest)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new RouteDialog(services, Accessor, ServiceManager, TelemetryClient));

            // Set starting dialog for component
            InitialDialogId = Action.FindPointOfInterest;
        }
예제 #17
0
        public FakeSkill(SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, ServiceManager serviceManager = null)
        {
            _skillMode           = skillMode;
            _services            = services ?? throw new ArgumentNullException(nameof(services));
            _userState           = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState   = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _proactiveState      = proactiveState;
            _endpointService     = endpointService;
            _backgroundTaskQueue = backgroundTaskQueue;
            _telemetryClient     = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _serviceManager      = serviceManager ?? new ServiceManager();

            if (responseManager == null)
            {
                var locales = new string[] { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" };
                responseManager = new ResponseManager(
                    locales,
                    new SampleAuthResponses(),
                    new MainResponses(),
                    new SharedResponses(),
                    new SampleResponses());
            }

            _responseManager = responseManager;
            _dialogs         = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
예제 #18
0
        public FakeSkill(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, bool skillMode = false, ResponseManager responseManager = null, ServiceManager serviceManager = null)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _serviceManager    = serviceManager ?? new ServiceManager();

            if (responseManager == null)
            {
                responseManager = new ResponseManager(
                    new IResponseIdCollection[]
                {
                    new SampleAuthResponses(),
                    new MainResponses(),
                    new SharedResponses(),
                    new SampleResponses()
                },
                    new string[] { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" });
            }

            _responseManager = responseManager;
            _dialogs         = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
예제 #19
0
        public TimeRemainingDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(TimeRemainingDialog), services, responseManager, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var timeRemain = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                CheckTimeRemain,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.ShowTimeRemaining, timeRemain)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Actions.ShowTimeRemaining;
        }
예제 #20
0
        public BookingDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <RestaurantBookingState> conversationStateAccessor,
            IStatePropertyAccessor <SkillUserState> userStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(BookingDialog), services, responseManager, conversationStateAccessor, userStateAccessor, serviceManager, telemetryClient)
        {
            _httpContext = httpContext;

            // Restaurant Booking waterfall
            var bookingWaterfall = new WaterfallStep[]
            {
                Init,
                AskForFoodType,
                AskForDate,
                AskForTime,
                AskForAttendeeCount,
                ConfirmSelectionBeforeBooking,
                AskForRestaurant,
                ProcessReservationAsync
            };

            AddDialog(new WaterfallDialog(Actions.BookRestaurant, bookingWaterfall));

            // Prompts
            AddDialog(new ChoicePrompt(Actions.AskForFoodType, ValidateFoodType)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    IncludeNumbers = true
                }
            });
            AddDialog(new DateTimePrompt(Actions.AskReservationDateStep, ValidateReservationDate));
            AddDialog(new DateTimePrompt(Actions.AskReservationTimeStep, ValidateReservationTime));
            AddDialog(new NumberPrompt <int>(Actions.AskAttendeeCountStep, ValidateAttendeeCount));
            AddDialog(new ConfirmPrompt(Actions.ConfirmSelectionBeforeBookingStep, ValidateBookingSelectionConfirmation));
            AddDialog(new ChoicePrompt(Actions.RestaurantPrompt, ValidateRestaurantSelection)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    IncludeNumbers = true
                }
            });

            // Optional
            AddDialog(new ChoicePrompt(Actions.AmbiguousTimePrompt, ValidateAmbiguousTimePrompt)
            {
                Style = ListStyle.HeroCard, ChoiceOptions = new ChoiceFactoryOptions {
                    IncludeNumbers = true
                }
            });

            // Set starting dialog for component
            InitialDialogId = Actions.BookRestaurant;

            // Used to help resolve image locations in both local deployment and remote
            _urlResolver = new UrlResolver(httpContext, services);
        }
예제 #21
0
        public VehicleSettingsDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <AutomotiveSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(VehicleSettingsDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.LocaleConfigurations["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.LocaleConfigurations["en"].LuisServices["settings_value"];

            // JSON resource files provided metatadata as to the available car settings, names and the values that can be set
            var resDir = Path.Combine(
                Path.GetDirectoryName(typeof(VehicleSettingsDialog).Assembly.Location),
                "Dialogs\\VehicleSettings\\Resources\\");

            settingList   = new SettingList(resDir + "available_settings.json", resDir + "setting_alternative_names.json");
            settingFilter = new SettingFilter(settingList);

            // Setting Change waterfall
            var processVehicleSettingChangeWaterfall = new WaterfallStep[]
            {
                ProcessSetting,
                ProcessVehicleSettingsChange,
                ProcessChange,
                SendChange
            };

            AddDialog(new WaterfallDialog(Actions.ProcessVehicleSettingChange, processVehicleSettingChangeWaterfall)
            {
                TelemetryClient = telemetryClient
            });

            // Prompts
            AddDialog(new ChoicePrompt(Actions.SettingNameSelectionPrompt, SettingNameSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
            AddDialog(new ChoicePrompt(Actions.SettingValueSelectionPrompt, SettingValueSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });

            AddDialog(new ConfirmPrompt(Actions.SettingConfirmationPrompt));

            // Set starting dialog for component
            InitialDialogId = Actions.ProcessVehicleSettingChange;

            // Used to resolve image paths (local or hosted)
            _httpContext = httpContext;
        }
예제 #22
0
        /// <summary>
        /// Gets the supported GeoSpatialService for reverse address search.
        /// Azure Maps is the only supported provider.
        /// </summary>
        /// <param name="services">The SkillConfigurationBase services.</param>
        /// <param name="locale">The user's locale.</param>
        /// <returns>IGeoSpatialService.</returns>
        public IGeoSpatialService InitAddressMapsService(SkillConfigurationBase services, string locale = "en-us")
        {
            services.Properties.TryGetValue("Radius", out var radius);
            radiusInt = (radius != null) ? Convert.ToInt32(radius) : radiusInt;

            var key = GetAzureMapsKey(services);

            return(new AzureMapsGeoSpatialService().InitKeyAsync(key, radiusInt, limitSizeInt, locale).Result);
        }
예제 #23
0
        public RouteDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(RouteDialog), services, responseManager, accessor, serviceManager, telemetryClient, httpContext)
        {
            TelemetryClient = telemetryClient;

            var checkForActiveRouteAndLocation = new WaterfallStep[]
            {
                CheckIfActiveRouteExists,
                CheckIfFoundLocationExists,
                CheckIfActiveLocationExists,
            };

            var findRouteToActiveLocation = new WaterfallStep[]
            {
                GetRoutesToActiveLocation,
                ResponseToStartRoutePrompt,
            };

            var findAlongRoute = new WaterfallStep[]
            {
                GetPointOfInterestLocations,
                ResponseToGetRoutePrompt,
            };

            var findPointOfInterest = new WaterfallStep[]
            {
                GetPointOfInterestLocations,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.GetActiveRoute, checkForActiveRouteAndLocation)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.FindAlongRoute, findAlongRoute)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.FindRouteToActiveLocation, findRouteToActiveLocation)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.FindPointOfInterest, findPointOfInterest)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Actions.GetActiveRoute;
        }
예제 #24
0
        public NewsSkill(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services;
            _conversationState = conversationState;
            _userState         = userState;
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _telemetryClient, _skillMode));
        }
예제 #25
0
 public NewsDialog(
     string dialogId,
     SkillConfigurationBase services,
     IStatePropertyAccessor <NewsSkillState> accessor,
     IBotTelemetryClient telemetryClient)
     : base(dialogId)
 {
     Services        = services;
     Accessor        = accessor;
     TelemetryClient = telemetryClient;
 }
예제 #26
0
        public CalendarSkill(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, IServiceManager serviceManager = null, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _serviceManager    = serviceManager ?? new ServiceManager(_services);
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
        public ReplyEmailDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <EmailSkillState> emailStateAccessor,
            IStatePropertyAccessor <DialogState> dialogStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(ReplyEmailDialog), services, responseManager, emailStateAccessor, dialogStateAccessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var replyEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                SetDisplayConfig,
                CollectSelectedEmail,
                AfterCollectSelectedEmail,
                CollectAdditionalText,
                AfterCollectAdditionalText,
                ConfirmBeforeSending,
                ReplyEmail,
            };

            var showEmail = new WaterfallStep[]
            {
                PagingStep,
                ShowEmails,
            };

            var updateSelectMessage = new WaterfallStep[]
            {
                UpdateMessage,
                PromptUpdateMessage,
                AfterUpdateMessage,
            };

            AddDialog(new WaterfallDialog(Actions.Reply, replyEmail));

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.Show, showEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.UpdateSelectMessage, updateSelectMessage)
            {
                TelemetryClient = telemetryClient
            });

            InitialDialogId = Actions.Reply;
        }
예제 #28
0
        public RestaurantBooking(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, ServiceManager serviceManager = null, IHttpContextAccessor httpContext = null, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _httpContext       = httpContext ?? throw new ArgumentNullException(nameof(httpContext));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _serviceManager    = serviceManager ?? new ServiceManager();
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _serviceManager, _telemetryClient, httpContext, _skillMode));
        }
예제 #29
0
 public RestaurantBookingDialog(
     string dialogId,
     SkillConfigurationBase services,
     IStatePropertyAccessor <RestaurantBookingState> accessor,
     IServiceManager serviceManager,
     IBotTelemetryClient telemetryClient)
     : base(nameof(RestaurantBookingDialog))
 {
     Services        = services;
     Accessor        = accessor;
     ServiceManager  = serviceManager;
     TelemetryClient = telemetryClient;
 }
예제 #30
0
 public AutomotiveSkillDialog(
     string dialogId,
     SkillConfigurationBase services,
     IStatePropertyAccessor <AutomotiveSkillState> accessor,
     IServiceManager serviceManager,
     IBotTelemetryClient telemetryClient)
     : base(dialogId)
 {
     Services        = services;
     Accessor        = accessor;
     ServiceManager  = serviceManager;
     TelemetryClient = telemetryClient;
 }