Exemplo n.º 1
0
        public RouteDialog(
            SkillConfiguration services,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager)
            : base(nameof(RouteDialog), services, accessor, serviceManager)
        {
            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(Action.GetActiveRoute, checkForActiveRouteAndLocation));
            AddDialog(new WaterfallDialog(Action.FindAlongRoute, findAlongRoute));
            AddDialog(new WaterfallDialog(Action.FindRouteToActiveLocation, findRouteToActiveLocation));
            AddDialog(new WaterfallDialog(Action.FindPointOfInterest, findPointOfInterest));

            // Set starting dialog for component
            InitialDialogId = Action.GetActiveRoute;
        }
Exemplo n.º 2
0
        public ReplyEmailDialog(
            ISkillConfiguration services,
            IStatePropertyAccessor <EmailSkillState> emailStateAccessor,
            IStatePropertyAccessor <DialogState> dialogStateAccessor,
            IServiceManager serviceManager)
            : base(nameof(ReplyEmailDialog), services, emailStateAccessor, dialogStateAccessor, serviceManager)
        {
            var replyEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                CollectSelectedEmail,
                CollectAdditionalText,
                ConfirmBeforeSending,
                ReplyEmail,
            };

            var showEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                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));
            AddDialog(new WaterfallDialog(Actions.UpdateSelectMessage, updateSelectMessage));

            InitialDialogId = Actions.Reply;
        }
Exemplo n.º 3
0
        public ToDoSkillDialog(
            string dialogId,
            ISkillConfiguration services,
            IStatePropertyAccessor<ToDoSkillState> accessor,
            ITaskService serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(dialogId)
        {
            Services = services;
            Accessor = accessor;
            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));
        }
Exemplo n.º 4
0
        public MainDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            UserState userState,
            ConversationState conversationState,
            SampleDialog sampleDialog,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _settings        = settings;
            _services        = services;
            _responseManager = responseManager;
            TelemetryClient  = telemetryClient;

            // Initialize state accessor
            _stateAccessor   = conversationState.CreateProperty <SkillState>(nameof(SkillState));
            _contextAccessor = userState.CreateProperty <SkillContext>(nameof(SkillContext));

            // Register dialogs
            AddDialog(sampleDialog);
        }
Exemplo n.º 5
0
        public AddToDoItemDialog(
            ISkillConfiguration services,
            IStatePropertyAccessor <ToDoSkillState> toDoStateAccessor,
            IStatePropertyAccessor <ToDoSkillUserState> userStateAccessor,
            ITaskService serviceManager,
            IMailService mailService,
            IBotTelemetryClient telemetryClient)
            : base(nameof(AddToDoItemDialog), services, toDoStateAccessor, userStateAccessor, serviceManager, mailService, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var addToDoTask = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ClearContext,
                CollectToDoTaskContent,
                AddToDoTask,
            };

            var collectToDoTaskContent = new WaterfallStep[]
            {
                AskToDoTaskContent,
                AfterAskToDoTaskContent,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Action.AddToDoTask, addToDoTask)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Action.CollectToDoTaskContent, collectToDoTaskContent)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Action.AddToDoTask;
        }
Exemplo n.º 6
0
        public MarkToDoItemDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <ToDoSkillState> toDoStateAccessor,
            IStatePropertyAccessor <ToDoSkillUserState> userStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MarkToDoItemDialog), services, toDoStateAccessor, userStateAccessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var markToDoTask = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ClearContext,
                InitAllTasks,
                CollectToDoTaskIndex,
                this.MarkToDoTaskCompleted,
            };

            var collectToDoTaskIndex = new WaterfallStep[]
            {
                AskToDoTaskIndex,
                AfterAskToDoTaskIndex,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Action.MarkToDoTaskCompleted, markToDoTask)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Action.CollectToDoTaskIndex, collectToDoTaskIndex)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Action.MarkToDoTaskCompleted;
        }
        public MainDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            ProactiveState proactiveState,
            CreateEventDialog createEventDialog,
            ChangeEventStatusDialog changeEventStatusDialog,
            TimeRemainingDialog timeRemainingDialog,
            ShowEventsDialog summaryDialog,
            UpdateEventDialog updateEventDialog,
            JoinEventDialog connectToMeetingDialog,
            UpcomingEventDialog upcomingEventDialog,
            CheckAvailableDialog checkAvailableDialog,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _settings          = settings;
            _services          = services;
            _userState         = userState;
            _responseManager   = responseManager;
            _conversationState = conversationState;
            TelemetryClient    = telemetryClient;

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

            // Register dialogs
            AddDialog(createEventDialog ?? throw new ArgumentNullException(nameof(createEventDialog)));
            AddDialog(changeEventStatusDialog ?? throw new ArgumentNullException(nameof(changeEventStatusDialog)));
            AddDialog(timeRemainingDialog ?? throw new ArgumentNullException(nameof(timeRemainingDialog)));
            AddDialog(summaryDialog ?? throw new ArgumentNullException(nameof(summaryDialog)));
            AddDialog(updateEventDialog ?? throw new ArgumentNullException(nameof(updateEventDialog)));
            AddDialog(connectToMeetingDialog ?? throw new ArgumentNullException(nameof(connectToMeetingDialog)));
            AddDialog(upcomingEventDialog ?? throw new ArgumentNullException(nameof(upcomingEventDialog)));
            AddDialog(checkAvailableDialog ?? throw new ArgumentNullException(nameof(checkAvailableDialog)));
        }
Exemplo n.º 8
0
        public MainDispatcher(
            BotServices services,
            IStatePropertyAccessor <OnTurnState> onTurnAccessor,
            UserState userState,
            ConversationState conversationState,
            ILoggerFactory loggerFactory,
            IPimbotServiceProvider provider)
            : base(nameof(MainDispatcher))
        {
            _services               = services ?? throw new ArgumentNullException(nameof(services));
            _logger                 = loggerFactory.CreateLogger <MainDispatcher>();
            _onTurnAccessor         = onTurnAccessor;
            _mainDispatcherAccessor = conversationState.CreateProperty <DialogState>(MainDispatcherStateProperty);
            _userState              = userState;
            _conversationState      = conversationState;
            _customerStateAccessor  = conversationState.CreateProperty <CustomerState>("customerProperty");

            if (conversationState == null)
            {
                throw new ArgumentNullException(nameof(conversationState));
            }

            if (userState == null)
            {
                throw new ArgumentNullException(nameof(userState));
            }

            _cartStateAccessor = userState.CreateProperty <CartState>(nameof(CartState));
            _dialogs           = new DialogSet(_mainDispatcherAccessor);
            AddDialog(new AddItemDialog(services, onTurnAccessor, _cartStateAccessor, provider));
            AddDialog(new RemoveItemDialog(services, onTurnAccessor, _cartStateAccessor));
            AddDialog(new GetUserInfoDialog(services, onTurnAccessor, _cartStateAccessor, _customerStateAccessor, provider));
            AddDialog(new FindItemDialog(services, onTurnAccessor, _cartStateAccessor, provider));
            AddDialog(new ShowCartDialog(services, onTurnAccessor, _cartStateAccessor, provider));
            AddDialog(new ShowOrdersDialog(services, onTurnAccessor, provider));
            AddDialog(new ShowCategoriesDialog(services, onTurnAccessor, provider));
            AddDialog(new DetailItemDialog(services, onTurnAccessor, provider));
        }
Exemplo n.º 9
0
        public SummaryDialog(
            ISkillConfiguration services,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(SummaryDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var showSummary = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                ShowEventsSummary,
                PromptToRead,
                CallReadEventDialog,
            };

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

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.ShowEventsSummary, showSummary)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Read, readEvent)
            {
                TelemetryClient = telemetryClient
            });

            // Set starting dialog for component
            InitialDialogId = Actions.ShowEventsSummary;
        }
Exemplo n.º 10
0
        public MainDialog(
            IServiceProvider serviceProvider)
            : base(nameof(MainDialog))
        {
            _settings        = serviceProvider.GetService <BotSettings>();
            _services        = serviceProvider.GetService <BotServices>();
            _templateManager = serviceProvider.GetService <LocaleTemplateManager>();

            // Create conversation state properties
            var conversationState = serviceProvider.GetService <ConversationState>();

            _stateAccessor = conversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState));

            var steps = new WaterfallStep[]
            {
                IntroStepAsync,
                RouteStepAsync,
                FinalStepAsync,
            };

            AddDialog(new WaterfallDialog(nameof(MainDialog), steps));
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            InitialDialogId = nameof(MainDialog);

            // Register dialogs
            _forwardEmailDialog = serviceProvider.GetService <ForwardEmailDialog>() ?? throw new ArgumentNullException(nameof(_forwardEmailDialog));
            _sendEmailDialog    = serviceProvider.GetService <SendEmailDialog>() ?? throw new ArgumentNullException(nameof(_sendEmailDialog));
            _showEmailDialog    = serviceProvider.GetService <ShowEmailDialog>() ?? throw new ArgumentNullException(nameof(_showEmailDialog));
            _replyEmailDialog   = serviceProvider.GetService <ReplyEmailDialog>() ?? throw new ArgumentNullException(nameof(_replyEmailDialog));
            _deleteEmailDialog  = serviceProvider.GetService <DeleteEmailDialog>() ?? throw new ArgumentNullException(nameof(_deleteEmailDialog));
            AddDialog(_forwardEmailDialog);
            AddDialog(_sendEmailDialog);
            AddDialog(_showEmailDialog);
            AddDialog(_replyEmailDialog);
            AddDialog(_deleteEmailDialog);

            GetReadingDisplayConfig();
        }
Exemplo n.º 11
0
 public RootDialog(ConversationState conversationState)
     : base(nameof(RootDialog))
 {
     this._conversationState = conversationState.CreateProperty <RootDialogState>(nameof(RootDialogState));
     this._privateState      = conversationState.CreateProperty <PrivateConversationData>(nameof(PrivateConversationData));
     InitialDialogId         = nameof(WaterfallDialog);
     AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
     {
         BeginRootDialogAsync
     }));
     AddDialog(new FetchRosterDialog(this._conversationState));
     AddDialog(new ListNamesDialog());
     AddDialog(new HelloDialog());
     AddDialog(new HelpDialog(this._conversationState));
     AddDialog(new MultiDialog1());
     AddDialog(new MultiDialog2(this._conversationState));
     AddDialog(new GetLastDialogUsedDialog(this._conversationState));
     AddDialog(new ProactiveMsgTo1to1Dialog(this._conversationState));
     AddDialog(new UpdateTextMsgSetupDialog(this._conversationState));
     AddDialog(new UpdateTextMsgDialog(this._conversationState));
     AddDialog(new UpdateCardMsgSetupDialog(this._conversationState));
     AddDialog(new UpdateCardMsgDialog(this._conversationState));
     AddDialog(new FetchTeamsInfoDialog(this._conversationState));
     AddDialog(new DeepLinkStaticTabDialog(this._conversationState));
     AddDialog(new AtMentionDialog(this._conversationState));
     AddDialog(new BeginDialogExampleDialog(this._conversationState));
     AddDialog(new HeroCardDialog(this._conversationState));
     AddDialog(new ThumbnailcardDialog(this._conversationState));
     AddDialog(new MessagebackDialog(this._conversationState));
     AddDialog(new AdaptiveCardDialog(this._conversationState));
     AddDialog(new PopupSigninCardDialog(this._conversationState));
     AddDialog(new QuizFullDialog(this._conversationState));
     AddDialog(new PromptDialog(this._conversationState));
     AddDialog(new DisplayCardsDialog(this._conversationState));
     AddDialog(new O365ConnectorCardActionsDialog(this._conversationState));
     AddDialog(new O365ConnectorCardDialog(this._conversationState));
     AddDialog(new SimpleFacebookAuthDialog());
 }
Exemplo n.º 12
0
        public CalendarSkillDialog(
            string dialogId,
            SkillConfigurationBase services,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(dialogId)
        {
            Services        = services;
            Accessor        = accessor;
            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(Actions.Prompt));
            AddDialog(new ConfirmPrompt(Actions.TakeFurtherAction, null, Culture.English)
            {
                Style = ListStyle.SuggestedAction
            });
            AddDialog(new DateTimePrompt(Actions.DateTimePrompt, DateTimeValidator, Culture.English));
            AddDialog(new DateTimePrompt(Actions.DateTimePromptForUpdateDelete, DateTimePromptValidator, Culture.English));
            AddDialog(new ChoicePrompt(Actions.Choice, ChoiceValidator, Culture.English)
            {
                Style = ListStyle.None,
            });
            AddDialog(new ChoicePrompt(Actions.EventChoice, null, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = false
                }
            });
        }
Exemplo n.º 13
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.Prompt, CustomPromptValidatorAsync));
            AddDialog(new ConfirmPrompt(Actions.ConfirmPrompt)
            {
                Style = ListStyle.Auto,
            });
        }
Exemplo n.º 14
0
        public OrderPizzaDialog(UserState userState, OrderPizzaRecognizer recognizer, IPizzaRepository pizzaRepository, IIngredientRepository ingredientRepository)
            : base(nameof(OrderPizzaDialog), userState, recognizer)
        {
            _userState            = userState;
            _pizzaRepository      = pizzaRepository;
            _ingredientRepository = ingredientRepository;
            _orderInfo            = _userState.CreateProperty <OrderInfo>("OrderInfo");

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new NumberPrompt <int>(nameof(NumberPrompt <int>), ValidateNumberOfPizas, "es"));
            AddDialog(new ChoicePrompt("ChoiceOrderType", ValidateOrderType, "es"));
            AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt), ValidateConfirmation, "es"));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                NumberOfPizzasAsync,
                OrderTypeAsync,
                ConfirmPizzaSelectionAsync,
                StartPizzaConfigurationAsync,
                EndTransactionAsync
            }));
            AddDialog(new PizzaSelectionDialog(_userState, Recognizer, _pizzaRepository, _ingredientRepository));
            InitialDialogId = nameof(WaterfallDialog);
        }
Exemplo n.º 15
0
        public OnboardingDialog(BotServices botServices, IStatePropertyAccessor <OnboardingState> accessor, IBotTelemetryClient telemetryClient)
            : base(botServices, nameof(OnboardingDialog), telemetryClient)
        {
            _accessor       = accessor;
            InitialDialogId = nameof(OnboardingDialog);

            var onboarding = new WaterfallStep[]
            {
                AskForName,
                AskForLocation,
                FinishOnboardingDialog,
            };

            // To capture built-in waterfall dialog telemetry, set the telemetry client
            // to the new waterfall dialog and add it to the component dialog
            TelemetryClient = telemetryClient;
            AddDialog(new WaterfallDialog(InitialDialogId, onboarding)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new TextPrompt(NamePrompt));
            AddDialog(new TextPrompt(LocationPrompt));
        }
Exemplo n.º 16
0
        public ToDoSkillDialog(
            string dialogId,
            SkillConfiguration services,
            IStatePropertyAccessor <ToDoSkillState> accessor,
            ITaskService serviceManager)
            : base(dialogId)
        {
            _services       = services;
            _accessor       = accessor;
            _serviceManager = serviceManager;

            var oauthSettings = new OAuthPromptSettings()
            {
                ConnectionName = _services.AuthConnectionName ?? throw new Exception("The authentication connection has not been initialized."),
                                       Text    = $"Authentication",
                                       Title   = "Signin",
                                       Timeout = 300000, // User has 5 minutes to login
            };

            AddDialog(new EventPrompt(SkillModeAuth, "tokens/response", TokenResponseValidator));
            AddDialog(new OAuthPrompt(LocalModeAuth, oauthSettings, AuthPromptValidator));
            AddDialog(new TextPrompt(Action.Prompt));
        }
Exemplo n.º 17
0
        public StartProcessDialog(IStatePropertyAccessor <ConversationFlow> conversationFlow)
            : base(nameof(StartProcessDialog))
        {
            _conversationFlow = conversationFlow;
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new StartProcessErrorDialog());
            AddDialog(new ParametersProcessDialog());
            AddDialog(new StartProcessSharedDialog());
            AddDialog(new RobotsDialog());
            var Steps = new WaterfallStep[]
            {
                IntroStepAsync,
                ShowProcessStepAsync,
                ConfirmStartProcessStepAsync,
                StartProcessStepAsync,
                GoServicenowStepAsync
            };

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), Steps));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
Exemplo n.º 18
0
        public CancelRouteDialog(
            SkillConfiguration services,
            IStatePropertyAccessor <PointOfInterestSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(CancelRouteDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

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

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

            // Set starting dialog for component
            InitialDialogId = Action.CancelActiveRoute;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicBot"/> class.
        /// </summary>
        /// <param name="botServices">Bot services.</param>
        /// <param name="accessors">Bot State Accessors.</param>
        public BasicBot(BotServices services, UserState userState, ConversationState conversationState, ILoggerFactory loggerFactory)
        {
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));

            _qnaStateAccessor      = _userState.CreateProperty <QnABotState>(nameof(QnABotState));
            _greetingStateAccessor = _userState.CreateProperty <GreetingState>(nameof(GreetingState));
            _dialogStateAccessor   = _conversationState.CreateProperty <DialogState>(nameof(DialogState));

            // Verify LUIS configuration.
            if (!_services.LuisServices.ContainsKey(LuisConfiguration))
            {
                throw new InvalidOperationException($"The bot configuration does not contain a service type of `luis` with the id `{LuisConfiguration}`.");
            }

            laLigaBL         = new LaLigaBL();
            luisServiceV3    = new LuisServiceV3();
            qnAServiceHelper = new QnAServiceHelper();

            Dialogs = new DialogSet(_dialogStateAccessor);
            Dialogs.Add(new GreetingDialog(_greetingStateAccessor, loggerFactory));
        }
Exemplo n.º 20
0
        public SampleDialog(
            SkillConfigurationBase services,
            IStatePropertyAccessor <SkillConversationState> conversationStateAccessor,
            IStatePropertyAccessor <SkillUserState> userStateAccessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(SampleDialog), services, conversationStateAccessor, userStateAccessor, serviceManager, telemetryClient)
        {
            var sample = new WaterfallStep[]
            {
                // NOTE: Uncomment these lines to include authentication steps to this dialog
                // GetAuthToken,
                // AfterGetAuthToken,
                PromptForName,
                GreetUser,
                End,
            };

            AddDialog(new WaterfallDialog(nameof(SampleDialog), sample));
            AddDialog(new TextPrompt(DialogIds.NamePrompt));

            InitialDialogId = nameof(SampleDialog);
        }
Exemplo n.º 21
0
        public Day3aDialog(UserState userState)
            : base(nameof(Day3aDialog))
        {
            _userProfileAccessor = userState.CreateProperty <UserProfile>("UserProfile");

            // This array defines how the Waterfall will execute.
            var waterfallSteps = new WaterfallStep[]
            {
                SCP20001StepAsync,
                SCP20009StepAsync
            };

            // Add named dialogs to the DialogSet. These names are saved in the dialog state.
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), waterfallSteps));
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            // AddDialog(new NumberPrompt<int>(nameof(NumberPrompt<int>), AgePromptValidatorAsync));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt)));
            // AddDialog(new AttachmentPrompt(nameof(AttachmentPrompt), PicturePromptValidatorAsync));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
Exemplo n.º 22
0
        public AskPerson(
            IPersonStore personStore,
            IStatePropertyAccessor <OnTurnProperty> onTurnPropertyAccessor,
            IStatePropertyAccessor <PersonInternState> personInternStateAccessor,
            IStatePropertyAccessor <DialogStateProperties> dialogStateProperties) : base(AskPersonInternId)
        {
            _personStore               = personStore;
            _onTurnPropertyAccessor    = onTurnPropertyAccessor;
            _personInternStateAccessor = personInternStateAccessor;
            _dialogStateProperties     = dialogStateProperties;

            var steps = new WaterfallStep[]
            {
                Initialize,
                CheckFirstState,
                CheckName,
                CheckDepartment
            };

            AddDialog(new WaterfallDialog(SearchDialog, steps));
            AddDialog(new TextPrompt(AskNameDialog));
            AddDialog(new TextPrompt(AskDepartmentDialog));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CoreBot"/> class.
        /// <param name="botServices">Bot services.</param>
        /// <param name="accessors">Bot State Accessors.</param>
        /// </summary>
        public ContactAssistantBot(StateBotAccessors accessors, BotServices services, UserState userState, ConversationState conversationState, ILoggerFactory loggerFactory)
        {
            _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors));

            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));

            _greetingStateAccessor = _userState.CreateProperty <GreetingState>(nameof(GreetingState));
            _dialogStateAccessor   = _conversationState.CreateProperty <DialogState>(nameof(DialogState));

            // Verify LUIS configuration.
            if (!_services.LuisServices.ContainsKey(LuisConfiguration))
            {
                throw new InvalidOperationException($"The bot configuration does not contain a service type of `luis` with the id `{LuisConfiguration}`.");
            }

            Dialogs = new DialogSet(_dialogStateAccessor);
            Dialogs.Add(new GreetingDialog(_greetingStateAccessor, loggerFactory));
            Dialogs.Add(new AddContactDialogue(_accessors, loggerFactory));
            Dialogs.Add(new ViewContactsDialogue(_accessors, loggerFactory));
            Dialogs.Add(new DeleteContactDialogue(_accessors, loggerFactory));
        }
Exemplo n.º 24
0
 public PizzaSelectionDialog(UserState userState, OrderPizzaRecognizer recognizer, IPizzaRepository pizzaRepository, IIngredientRepository ingredientRepository)
     : base(nameof(PizzaSelectionDialog), userState, recognizer)
 {
     _userState            = userState;
     _pizzaRepository      = pizzaRepository;
     _ingredientRepository = ingredientRepository;
     _orderInfo            = _userState.CreateProperty <OrderInfo>("OrderInfo");
     AddDialog(new TextPrompt("ChoosePizza", ValidatePizza));
     AddDialog(new ChoicePrompt("ChoicePizzaSize", ValidateMaxAttemptsReached, "es"));
     AddDialog(new ChoicePrompt("ChoicePizzaDough", ValidateMaxAttemptsReached, "es"));
     AddDialog(new ConfirmPrompt("ConfirmPizzaConfiguration", ValidateConfirmation, "es"));
     AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
     {
         AskForPizzaAsync,
         SetPizzaAsync,
         AskForPizzaSizeAsync,
         AskForDoughTypeAsync,
         ConfirmPizzaAsync,
         EndPizzaAsync,
     }));
     AddDialog(new CustomPizzaDialog(_userState, Recognizer, _pizzaRepository, _ingredientRepository));
     InitialDialogId = nameof(WaterfallDialog);
 }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfirmDropoffDialog"/> class.
        /// </summary>
        /// <param name="stateAccessor">The <see cref="ConversationState"/> for storing properties at conversation-scope.</param>
        /// <param name="telemetryClient">Telemetry client.</param>
        public ConfirmDropoffDialog(IStatePropertyAccessor <ConfirmDropoffState> stateAccessor, TelemetryClient telemetryClient) : base(nameof(ConfirmDropoffDialog))
        {
            _stateAccessor   = stateAccessor ?? throw new ArgumentNullException(nameof(stateAccessor));
            _telemetryClient = telemetryClient;

            var dialogSteps = new WaterfallStep[]
            {
                InitializeStateStepAsync,
                SelectReservationStepAsync,
                PromptForBuildingStepAsync,
                PromptForFloorStepAsync,
                PromptForSeatStepAsync,
                DisplayDropoffConfirmationStepAsync,
            };

            AddDialog(new WaterfallDialog(Name, dialogSteps));
            AddDialog(AuthDialog.LoginPromptDialog());
            AddDialog(new FindReservationDialog(telemetryClient));

            AddDialog(new ChoicePrompt(BuildingPromptName));
            AddDialog(new ChoicePrompt(FloorPromptName));
            AddDialog(new TextPrompt(SeatPromptName, ValidateSeat));
        }
        public UserProfileDialog(UserState userState)
            : base(nameof(UserProfileDialog))
        {
            _userProfileAccessor = userState.CreateProperty <UserProfile>("UserProfile");

            // This array defines how the Waterfall will execute.
            var waterfallSteps = new WaterfallStep[]
            {
                askNameAsync,
                AskCompanyNameAsync,
                AskPhoneAsync,
                DisplayAsync
            };

            // Add named dialogs to the DialogSet. These names are saved in the dialog state.
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), waterfallSteps));
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new NumberPrompt <long>(nameof(NumberPrompt <long>)));


            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
Exemplo n.º 27
0
        public LoginDialog(ConversationState conversationState, LoginState state, IMessagesService messagesService)
            : base(nameof(LoginDialog), conversationState, messagesService)
        {
            // Get Conversation State Accessor
            conversationStateAccessor = conversationState.CreateProperty <ConversationData>(nameof(ConversationData));

            loginStateAccessor = conversationState.CreateProperty <LoginState>(nameof(LoginState));

            this.messagesService = messagesService;

            AddDialog(new TextPrompt(NamePrompt, NameValidator));
            AddDialog(new TextPrompt(PinPrompt, PinValidator));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                InitialStepAsync,
                NameStepAsync,
                PinStepAsync,
                EndStepAsync,
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
Exemplo n.º 28
0
        public SendEmailDialog(UserState userState, IConfiguration configuration)
            : base(nameof(SendEmailDialog))
        {
            Configuration = configuration;
            UserState     = userState;

            var connectionName = Configuration.GetSection("ConnectionName")?.Value;

            _originatorId = Configuration.GetSection("OriginatorId")?.Value;

            _targetEmail = userState.CreateProperty <string>(TargetEmailProperty);

            var steps = new WaterfallStep[] {
                SignInAsync,
                DisplayTokenAsync,
            };

            AddDialog(new WaterfallDialog(nameof(SendEmailDialog), steps));
            AddDialog(new OAuthPrompt(nameof(OAuthPrompt), new OAuthPromptSettings()
            {
                ConnectionName = connectionName, Text = "Please sign in to continue", Title = "Sign In"
            }));
        }
Exemplo n.º 29
0
        public MainDialog(
            SkillConfigurationBase services,
            ConversationState conversationState,
            UserState userState,
            IBotTelemetryClient telemetryClient,
            IServiceManager serviceManager,
            bool skillMode)
            : base(nameof(MainDialog), telemetryClient)
        {
            _skillMode         = skillMode;
            _services          = services;
            _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();
        }
Exemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicBot"/> class.
        /// </summary>
        /// <param name="botServices">Bot services.</param>
        /// <param name="accessors">Bot State Accessors.</param>
        public BasicBot(BotServices services, UserState userState, ConversationState conversationState, ILoggerFactory loggerFactory)
        {
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));

            _greetingStateAccessor = _userState.CreateProperty <GreetingState>(nameof(GreetingState));
            _productStateAccessor  = _userState.CreateProperty <ProductState>(nameof(ProductState));
            _shoesStateAccessor    = _userState.CreateProperty <ShoesState>(nameof(ShoesState));
            _clothingStateAccessor = _userState.CreateProperty <ClothingState>(nameof(ClothingState));
            _dialogStateAccessor   = _conversationState.CreateProperty <DialogState>(nameof(DialogState));

            // Verify LUIS configuration.
            if (!_services.LuisServices.ContainsKey(LuisConfiguration))
            {
                throw new InvalidOperationException($"The bot configuration does not contain a service type of `luis` with the id `{LuisConfiguration}`.");
            }

            Dialogs = new DialogSet(_dialogStateAccessor);
            Dialogs.Add(new GreetingDialog(_greetingStateAccessor, loggerFactory));
            Dialogs.Add(new ShoesDialog(_productStateAccessor, loggerFactory));
            Dialogs.Add(new ClothingDialog(_clothingStateAccessor, loggerFactory));
        }