Proactive Activities
The BotBuilder proactive message flow requires you to have a conversation reference stored somewhere. In Teams AI
we expose a send method almost identical to the one passed into our activity handlers that accepts a conversationId,
so all you need to store is that!
- Diff
- BotBuilder
- Teams AI
-    import {
-      CloudAdapter,
-      ConfigurationBotFrameworkAuthentication,
-      ConversationReference,
-    } from 'botbuilder';
+    import { App } from '@microsoft/teams.apps';
-    const auth = new ConfigurationBotFrameworkAuthentication(process.env);
-    const adapter = new CloudAdapter(auth);
+    const app = new App();
(async () => {
-      const conversationReference: ConversationReference = {
-        serviceUrl: '...',
-        bot: { ... },
-        channelId: 'msteams',
-        conversation: { ... },
-        user: { ... },
-      };
-      await adapter.continueConversationAsync(process.env.MicrosoftAppId ?? '', conversationReference, async context => {
-        await context.sendActivity('proactive hello');
-      });
+      await app.start();
+      await app.send('your-conversation-id', 'proactive hello');
}());
import {
  CloudAdapter,
  ConfigurationBotFrameworkAuthentication,
  ConversationReference,
} from 'botbuilder';
const auth = new ConfigurationBotFrameworkAuthentication(process.env);
const adapter = new CloudAdapter(auth);
(async () => {
  const conversationReference: ConversationReference = {
    serviceUrl: '...',
    bot: { ... },
    channelId: 'msteams',
    conversation: { ... },
    user: { ... },
  };
  await adapter.continueConversationAsync(process.env.MicrosoftAppId ?? '', conversationReference, async context => {
    await context.sendActivity('proactive hello');
  });
}());
import { App } from '@microsoft/teams.apps';
const app = new App();
(async () => {
  await app.start();
  await app.send('your-conversation-id', 'proactive hello');
}());