示例#1
0
        public MainDialog(
            BotSettings settings,
            BotServices services,
            OnboardingDialog onboardingDialog,
            EscalateDialog escalateDialog,
            CancelDialog cancelDialog,
            List <SkillDialog> skillDialogs,
            IBotTelemetryClient telemetryClient,
            UserState userState)
            : base(nameof(MainDialog), telemetryClient)
        {
            _settings             = settings;
            _services             = services;
            TelemetryClient       = telemetryClient;
            _onboardingState      = userState.CreateProperty <OnboardingState>(nameof(OnboardingState));
            _skillContextAccessor = userState.CreateProperty <SkillContext>(nameof(SkillContext));

            AddDialog(onboardingDialog);
            AddDialog(escalateDialog);
            AddDialog(cancelDialog);

            foreach (var skillDialog in skillDialogs)
            {
                AddDialog(skillDialog);
            }
        }
示例#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)
            : base(nameof(MainDialog))
        {
            _settings        = serviceProvider.GetService <BotSettings>();
            _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>();
            _templateEngine = serviceProvider.GetService <LocaleTemplateEngineManager>();
            _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: _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);
            }
        }