diff --git a/packages/botbuilder-adapter-slack/src/botworker.ts b/packages/botbuilder-adapter-slack/src/botworker.ts index 00f0cd269..1a9f6f72f 100644 --- a/packages/botbuilder-adapter-slack/src/botworker.ts +++ b/packages/botbuilder-adapter-slack/src/botworker.ts @@ -268,7 +268,7 @@ export class SlackBotWorker extends BotWorker { msg.conversation.thread_ts = src.incoming_message.channelData.thread_ts; } - msg = this.getConfig('context').adapter.activityToSlack(msg); + msg = this.getConfig('adapter').activityToSlack(msg); const requestOptions = { uri: src.incoming_message.channelData.response_url, @@ -336,7 +336,7 @@ export class SlackBotWorker extends BotWorker { * @param update An object in the form `{id: , conversation: { id: }, text: , card: }` */ public async updateMessage(update: Partial): Promise { - return this.getConfig('context').adapter.updateActivity( + return this.getConfig('adapter').updateActivity( this.getConfig('context'), update ); @@ -356,7 +356,7 @@ export class SlackBotWorker extends BotWorker { * @param update An object in the form of `{id: , conversation: { id: }}` */ public async deleteMessage(update: Partial): Promise { - return this.getConfig('context').adapter.deleteActivity( + return this.getConfig('adapter').deleteActivity( this.getConfig('context'), { activityId: update.id, diff --git a/packages/botkit/src/botworker.ts b/packages/botkit/src/botworker.ts index 62c2b8cc0..2c35dee0c 100644 --- a/packages/botkit/src/botworker.ts +++ b/packages/botkit/src/botworker.ts @@ -259,7 +259,7 @@ export class BotWorker { ); // create a turn context - const turnContext = new TurnContext(this.getConfig('context').adapter, activity as Activity); + const turnContext = new TurnContext(this.getConfig('adapter'), activity as Activity); // create a new dialogContext so beginDialog works. const dialogContext = await this._controller.dialogSet.createContext(turnContext); @@ -278,7 +278,7 @@ export class BotWorker { // Create conversation const parameters: ConversationParameters = { bot: reference.bot, members: [reference.user], isGroup: false, activity: null, channelData: null }; - const client = this.getConfig('context').adapter.createConnectorClient(reference.serviceUrl); + const client = this.getConfig('adapter').createConnectorClient(reference.serviceUrl); // Mix in the tenant ID if specified. This is required for MS Teams. if (reference.conversation && reference.conversation.tenantId) { @@ -312,7 +312,7 @@ export class BotWorker { if (response.serviceUrl) { request.serviceUrl = response.serviceUrl; } // Create context and run middleware - const turnContext: TurnContext = this.getConfig('context').adapter.createContext(request); + const turnContext: TurnContext = this.getConfig('adapter').createContext(request); // create a new dialogContext so beginDialog works. const dialogContext = await this._controller.dialogSet.createContext(turnContext); diff --git a/packages/botkit/src/core.ts b/packages/botkit/src/core.ts index a9245406d..86f8bfa71 100644 --- a/packages/botkit/src/core.ts +++ b/packages/botkit/src/core.ts @@ -1077,7 +1077,8 @@ export class Botkit { } let worker: BotWorker = null; - const adapter = custom_adapter || config.context.adapter || this.adapter; + const adapter = custom_adapter || (config.context && config.context.adapter) ? config.context.adapter : this.adapter; + if (adapter.botkit_worker) { const CustomBotWorker = adapter.botkit_worker; worker = new CustomBotWorker(this, config); @@ -1085,6 +1086,9 @@ export class Botkit { worker = new BotWorker(this, config); } + // make sure the adapter is available in a standard location. + worker.getConfig().adapter = adapter; + return new Promise((resolve, reject) => { this.middleware.spawn.run(worker, (err, worker) => { if (err) {