public MainDialog(
            IServiceProvider serviceProvider)
            : base(nameof(MainDialog))
        {
            _services        = serviceProvider.GetService <BotServices>();
            _templateManager = serviceProvider.GetService <LocaleTemplateManager>();
            _skillsConfig    = serviceProvider.GetService <SkillsConfiguration>();
            _feedbackOptions = serviceProvider.GetService <FeedbackOptions>();
            TelemetryClient  = serviceProvider.GetService <IBotTelemetryClient>();

            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));

            var conversationState = serviceProvider.GetService <ConversationState>();

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

            // Create state property to track the active skill.
            _activeSkillProperty = conversationState.CreateProperty <BotFrameworkSkill>(ActiveSkillPropertyName);
            _feedbackAccessor    = conversationState.CreateProperty <FeedbackRecord>(nameof(FeedbackRecord));

            var steps = new List <WaterfallStep>()
            {
                OnboardingStepAsync,
                IntroStepAsync,
                RouteStepAsync,
                FinalStepAsync,
            };

            // Add FeedbackSteps
            if (_feedbackOptions.FeedbackEnabled)
            {
                steps.Add(RequestFeedback);
                steps.Add(RequestFeedbackComment);
                steps.Add(ProcessFeedback);
                AddDialog(new TextPrompt(DialogIds.FeedbackPrompt));
                AddDialog(new TextPrompt(DialogIds.FeedbackCommentPrompt));
            }

            steps.Add(FinalStepAsync);

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

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
示例#2
0
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _services       = serviceProvider.GetService <BotServices>();
            _settings       = serviceProvider.GetService <BotSettings>();
            _templateEngine = serviceProvider.GetService <LocaleTemplateEngineManager>();
            TelemetryClient = telemetryClient;

            // Create user state properties
            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));
            _skillContext     = userState.CreateProperty <SkillContext>(nameof(SkillContext));

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

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient,
            MicrosoftAppCredentials appCredentials,
            ProactiveState proactiveState)
            : base(nameof(MainDialog), telemetryClient)
        {
            _services       = serviceProvider.GetService <BotServices>();
            _settings       = serviceProvider.GetService <BotSettings>();
            _templateEngine = serviceProvider.GetService <LocaleTemplateEngineManager>();
            TelemetryClient = telemetryClient;

            // Create user state properties
            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));
            _skillContext     = userState.CreateProperty <SkillContext>(nameof(SkillContext));

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

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

            // SAMPLE: Create proactive state properties
            _appCredentials         = appCredentials;
            _proactiveStateAccessor = proactiveState.CreateProperty <ProactiveModel>(nameof(ProactiveModel));

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register a QnAMakerDialog for each registered knowledgebase and ensure localised responses are provided.
            var localizedServices = _services.GetCognitiveModels();

            foreach (var knowledgebase in localizedServices.QnAConfiguration)
            {
                var qnaDialog = new QnAMakerDialog(
                    knowledgeBaseId: knowledgebase.Value.KnowledgeBaseId,
                    endpointKey: knowledgebase.Value.EndpointKey,
                    hostName: knowledgebase.Value.Host,
                    noAnswer: _templateEngine.GenerateActivityForLocale("UnsupportedMessage"),
                    activeLearningCardTitle: _templateEngine.GenerateActivityForLocale("QnaMakerAdaptiveLearningCardTitle").Text,
                    cardNoMatchText: _templateEngine.GenerateActivityForLocale("QnaMakerNoMatchText").Text)
                {
                    Id = knowledgebase.Key
                };
                AddDialog(qnaDialog);
            }

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
示例#4
0
        public MainDialog(
            IServiceProvider serviceProvider)
            : base(nameof(MainDialog))
        {
            _serviceProvider = serviceProvider;
            _services        = serviceProvider.GetService <BotServices>();
            _templateManager = serviceProvider.GetService <LocaleTemplateManager>();
            _skillsConfig    = serviceProvider.GetService <SkillsConfiguration>();

            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));

            var conversationState = serviceProvider.GetService <ConversationState>();

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

            // Create state property to track the active skill.
            _activeSkillProperty = conversationState.CreateProperty <BotFrameworkSkill>(ActiveSkillPropertyName);

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

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

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient
            )
            : base(nameof(MainDialog))
        {
            _services        = serviceProvider.GetService <BotServices>();
            _settings        = serviceProvider.GetService <BotSettings>();
            _templateManager = serviceProvider.GetService <LocaleTemplateManager>();
            _skillsConfig    = serviceProvider.GetService <SkillsConfiguration>();
            _feedbackOptions = serviceProvider.GetService <FeedbackOptions>();
            TelemetryClient  = telemetryClient;

            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));

            var conversationState = serviceProvider.GetService <ConversationState>();

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);
            _feedbackAccessor         = conversationState.CreateProperty <FeedbackRecord>(nameof(FeedbackRecord));

            var steps = new List <WaterfallStep>()
            {
                OnboardingStepAsync,
                IntroStepAsync,
                RouteStepAsync,
            };

            if (_feedbackOptions.FeedbackEnabled)
            {
                steps.Add(RequestFeedback);
                steps.Add(RequestFeedbackComment);
                steps.Add(ProcessFeedback);
                AddDialog(new TextPrompt(DialogIds.FeedbackPrompt));
                AddDialog(new TextPrompt(DialogIds.FeedbackCommentPrompt));
            }
            steps.Add(FinalStepAsync);

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

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register a QnAMakerDialog for each registered knowledgebase and ensure localised responses are provided.
            var localizedServices = _services.GetCognitiveModels();

            foreach (var knowledgebase in localizedServices.QnAConfiguration)
            {
                var qnaDialog = new QnAMakerDialog(
                    knowledgeBaseId: knowledgebase.Value.KnowledgeBaseId,
                    endpointKey: knowledgebase.Value.EndpointKey,
                    hostName: knowledgebase.Value.Host,
                    noAnswer: _templateManager.GenerateActivityForLocale("UnsupportedMessage"),
                    activeLearningCardTitle: _templateManager.GenerateActivityForLocale("QnaMakerAdaptiveLearningCardTitle").Text,
                    cardNoMatchText: _templateManager.GenerateActivityForLocale("QnaMakerNoMatchText").Text)
                {
                    Id = knowledgebase.Key
                };
                AddDialog(qnaDialog);
            }

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
示例#6
0
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog))
        {
            _services       = serviceProvider.GetService <BotServices>();
            _settings       = serviceProvider.GetService <BotSettings>();
            _skillsConfig   = serviceProvider.GetService <SkillsConfiguration>();
            TelemetryClient = telemetryClient;

            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));

            var conversationState = serviceProvider.GetService <ConversationState>();

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

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

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

            // Register dialogs
            _onboardingDialog  = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog = serviceProvider.GetService <SwitchSkillDialog>();
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);

            // Register a QnAMakerDialog for each registered knowledgebase and ensure localised responses are provided.
            var localizedServices = _services.GetCognitiveModels();

            foreach (var knowledgebase in localizedServices.QnAConfiguration)
            {
                var qnaDialog = new QnAMakerDialog(
                    knowledgeBaseId: knowledgebase.Value.KnowledgeBaseId,
                    endpointKey: knowledgebase.Value.EndpointKey,
                    hostName: knowledgebase.Value.Host,
                    noAnswer: MessageFactory.Text("Not supported"),               //_templateEngine.GenerateActivityForLocale("UnsupportedMessage"),
                    activeLearningCardTitle: "QnaMakerAdaptiveLearningCardTitle", // _templateEngine.GenerateActivityForLocale("QnaMakerAdaptiveLearningCardTitle").Text,
                    cardNoMatchText: "No QnA match")
                {
                    Id = knowledgebase.Key
                };
                AddDialog(qnaDialog);
            }

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }
示例#7
0
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), serviceProvider, telemetryClient)
        {
            _services       = serviceProvider.GetService <BotServices>();
            _settings       = serviceProvider.GetService <BotSettings>();
            _templateEngine = serviceProvider.GetService <LocaleTemplateEngineManager>();
            _skillsConfig   = serviceProvider.GetService <SkillsConfiguration>();

            var userState = serviceProvider.GetService <UserState>();

            _userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));
            var conversationState = serviceProvider.GetService <ConversationState>();

            _previousResponseAccessor = conversationState.CreateProperty <List <Activity> >(StateProperties.PreviousBotResponse);

            WaterfallStep[] steps = SetupWaterfallSteps();

            AddDialog(new WaterfallDialog(nameof(MainDialog), steps));
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt))
            {
                Style = ListStyle.HeroCard
            });
            InitialDialogId = nameof(MainDialog);

            // Register dialogs
            _oauthPrompt              = serviceProvider.GetService <OAuthPrompt>();
            _loginDialog              = serviceProvider.GetService <LoginDialog>();
            _onboardingDialog         = serviceProvider.GetService <OnboardingDialog>();
            _switchSkillDialog        = serviceProvider.GetService <SwitchSkillDialog>();
            _escalateDialog           = serviceProvider.GetService <EscalateDialog>();
            _cancelDialog             = serviceProvider.GetService <CancelDialog>();
            _entertainDialog          = serviceProvider.GetService <EntertainDialog>();
            _chitchatdialog           = serviceProvider.GetService <ChitchatDialog>();
            _stressDialog             = serviceProvider.GetService <StressDialog>();
            _highstresshandlingDialog = serviceProvider.GetService <HighStressHandlingDialog>();
            _stresshandlingDialog     = serviceProvider.GetService <StressHandlingDialog>();
            _journalingDialog         = serviceProvider.GetService <JournalingDialog>();

            AddDialog(_oauthPrompt);
            AddDialog(_loginDialog);
            AddDialog(_onboardingDialog);
            AddDialog(_switchSkillDialog);
            AddDialog(_escalateDialog);
            AddDialog(_cancelDialog);
            AddDialog(_entertainDialog);
            AddDialog(_chitchatdialog);
            AddDialog(_stressDialog);
            AddDialog(_highstresshandlingDialog);
            AddDialog(_stresshandlingDialog);
            AddDialog(_journalingDialog);



            // Register a QnAMakerDialog for each registered knowledgebase and ensure localised responses are provided.
            var localizedServices = _services.GetCognitiveModels();

            foreach (var knowledgebase in localizedServices.QnAConfiguration)
            {
                var qnaDialog = new QnAMakerDialog(
                    knowledgeBaseId: knowledgebase.Value.KnowledgeBaseId,
                    endpointKey: knowledgebase.Value.EndpointKey,
                    hostName: knowledgebase.Value.Host,
                    noAnswer: _templateEngine.GenerateActivityForLocale("UnsupportedMessage"),
                    activeLearningCardTitle: _templateEngine.GenerateActivityForLocale("QnaMakerAdaptiveLearningCardTitle").Text,
                    cardNoMatchText: _templateEngine.GenerateActivityForLocale("QnaMakerNoMatchText").Text)
                {
                    Id = knowledgebase.Key
                };
                AddDialog(qnaDialog);
            }

            // Register skill dialogs
            var skillDialogs = serviceProvider.GetServices <SkillDialog>();

            foreach (var dialog in skillDialogs)
            {
                AddDialog(dialog);
            }
        }