Adapters
A BotBuilder Adapter is similar to a Teams AI Plugin in the sense that they are both
an abstraction that is meant to send/receive activities. To make migrating stress free we have
shipped a pre-built BotBuilderPlugin that can accept a botbuilder Adapter instance.
info
this snippet shows how to use the BotBuilderPlugin to send/receive activities using
botbuilder instead of the default Teams AI http plugin.
- index.ts
- adapter.ts
- activity-handler.ts
import { App } from '@microsoft/teams.apps';
import { BotBuilderPlugin } from '@microsoft/teams.botbuilder';
import adapter from './adapter';
import handler from './activity-handler';
const app = new App({
  plugins: [new BotBuilderPlugin({ adapter, handler })],
});
app.on('message', async ({ send }) => {
  await send('hi from teams...');
});
(async () => {
  await app.start();
})();
import { CloudAdapter } from 'botbuilder';
// replace with your BotAdapter
const adapter = new CloudAdapter(
  new ConfigurationBotFrameworkAuthentication(
    {},
    new ConfigurationServiceClientCredentialFactory({
      MicrosoftAppType: tenantId ? 'SingleTenant' : 'MultiTenant',
      MicrosoftAppId: clientId,
      MicrosoftAppPassword: clientSecret,
      MicrosoftAppTenantId: tenantId,
    })
  )
);
export default adapter;
import { TeamsActivityHandler } from 'botbuilder';
// replace with your TeamsActivityHandler
export class ActivityHandler extends TeamsActivityHandler {
  constructor() {
    super();
    this.onMessage(async (ctx, next) => {
      await ctx.sendActivity('hi from botbuilder...');
      await next();
    });
  }
}
const handler = new ActivityHandler();
export default handler;
hi from botbuilder...
hi from teams...