コード例 #1
0
        private void SetUpTurnState(ITurnContext turnContext, BotFrameworkClient botFrameworkClient)
        {
            turnContext.TurnState.Add(botFrameworkClient);
            turnContext.TurnState.Add(_skillConversationIdFactoryBase);
            turnContext.TurnState.Add(_conversationState);
            turnContext.TurnState.Add(_userState);
            turnContext.TurnState.Add(_resourceExplorer);
            turnContext.TurnState.Add(_memoryScopes);
            turnContext.TurnState.Add(_pathResolvers);
            turnContext.TurnState.Add(_resourceExplorer.TryGetResource(_languageGeneratorId, out var resource) ? (LanguageGenerator) new ResourceMultiLanguageGenerator(_languageGeneratorId) : new TemplateEngineLanguageGenerator());
            turnContext.TurnState.Add(_languageGeneratorManagers.GetOrAdd(_resourceExplorer, _ => new LanguageGeneratorManager(_resourceExplorer)));
            turnContext.TurnState.Add(_languagePolicy);
            turnContext.TurnState.Add(_telemetryClient);

            // put this on the TurnState using Set because some adapters (like BotFrameworkAdapter and CloudAdapter) will have already added it
            turnContext.TurnState.Set <BotCallbackHandler>(OnTurnAsync);
        }
コード例 #2
0
        public DefaultAdapter(
            BotSettings settings,
            ICredentialProvider credentialProvider,
            IChannelProvider channelProvider,
            AuthenticationConfiguration authConfig,
            LocaleTemplateManager templateEngine,
            ConversationState conversationState,
            TelemetryInitializerMiddleware telemetryMiddleware,
            IBotTelemetryClient telemetryClient,
            ILogger <BotFrameworkHttpAdapter> logger,
            IStorage storage,
            UserState userState,
            IConfiguration configuration,
            SkillConversationIdFactoryBase skillConversationIdFactoryBase,
            BotFrameworkClient botFrameworkClient)
            : base(credentialProvider, authConfig, channelProvider, logger: logger)
        {
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
            _templateEngine    = templateEngine ?? throw new ArgumentNullException(nameof(templateEngine));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _skillConversationIdFactoryBase = skillConversationIdFactoryBase;

            OnTurnError = HandleTurnErrorAsync;

            Use(telemetryMiddleware);

            // Uncomment the following line for local development without Azure Storage
            Use(new TranscriptLoggerMiddleware(new MemoryTranscriptStore()));
            //Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container)));
            Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true));
            Use(new ShowTypingMiddleware());
            Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));
            Use(new EventDebuggerMiddleware());
            Use(new SetSpeakMiddleware());
            Use(new RegisterClassMiddleware <SkillConversationIdFactoryBase>(_skillConversationIdFactoryBase));
            Use(new RegisterClassMiddleware <BotFrameworkClient>(botFrameworkClient));

            //from instructions: https://microsoft.github.io/botframework-solutions/skills/handbook/experimental-add-composer/
            this.Use(new RegisterClassMiddleware <IConfiguration>(configuration));
            this.UseStorage(storage);
            this.UseBotState(userState);
            this.UseBotState(conversationState);
        }
コード例 #3
0
        public TestBot(ConversationState conversationState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory)
        {
            HostContext.Current.Set(skillClient);
            HostContext.Current.Set(conversationIdFactory);
            this.dialogStateAccessor = conversationState.CreateProperty <DialogState>("RootDialogState");
            this.resourceExplorer    = resourceExplorer;

            // auto reload dialogs when file changes
            this.resourceExplorer.Changed += (resources) =>
            {
                if (resources.Any(resource => resource.Id.EndsWith(".dialog") || resource.Id.EndsWith(".lg")))
                {
                    Task.Run(() => this.LoadDialogs());
                }
            };
            LoadDialogs();
        }
コード例 #4
0
 public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, string rootDialog)
 {
     HostContext.Current.Set(skillClient);
     HostContext.Current.Set(conversationIdFactory);
     this.conversationState = conversationState;
     this.userState         = userState;
     this.dialogState       = conversationState.CreateProperty <DialogState>("DialogState");
     this.resourceExplorer  = resourceExplorer;
     this.rootDialogFile    = rootDialog;
     LoadRootDialogAsync();
 }
コード例 #5
0
        public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, IBotTelemetryClient telemetryClient, string rootDialog, string defaultLocale, bool removeRecipientMention = false)
        {
            this.conversationState      = conversationState;
            this.userState              = userState;
            this.dialogState            = conversationState.CreateProperty <DialogState>("DialogState");
            this.resourceExplorer       = resourceExplorer;
            this.rootDialogFile         = rootDialog;
            this.defaultLocale          = defaultLocale;
            this.telemetryClient        = telemetryClient;
            this.removeRecipientMention = removeRecipientMention;

            LoadRootDialogAsync();
            if (skillClient != null)
            {
                this.dialogManager.InitialTurnState.Set(skillClient);
            }

            this.dialogManager.InitialTurnState.Set(conversationIdFactory);
        }
コード例 #6
0
 public ComposerBotWithSms(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, IBotTelemetryClient telemetryClient, string rootDialog, string defaultLocale, AcsSmsAdapter acsSmsAdapter, IConfiguration configuration, bool removeRecipientMention = false)
     : base(conversationState, userState, resourceExplorer, skillClient, conversationIdFactory, telemetryClient, rootDialog, defaultLocale, removeRecipientMention)
 {
     _acsSmsAdapter = acsSmsAdapter;
     _configuration = configuration;
 }