Skip to main content

Proactive Activities

The BotBuilder proactive message flow requires storing a conversation reference. In Teams SDK, we expose a SendAsync method in the App class, almost identical to the one passed into our activity handlers through our context. This method accepts a conversationId , so storing just that is enough!

-   using Microsoft.Bot.Builder;
- using Microsoft.Bot.Builder.Integration.AspNet.Core;
- using Microsoft.Bot.Schema;
+ using Microsoft.Teams.Apps;

- var conversationReference = new ConversationReference
- {
- ServiceUrl = "...",
- Bot = new ChannelAccount { ... },
- ChannelId = "msteams",
- Conversation = new ConversationAccount { ... },
- User = new ChannelAccount { ... }
- };
-
- await adapter.ContinueConversationAsync(
- configuration["MicrosoftAppId"],
- conversationReference,
- async (turnContext, cancellationToken) =>
- {
- await turnContext.SendActivityAsync("proactive hello", cancellationToken: cancellationToken);
- },
- default);
+ var teams = app.UseTeams();
+ await teams.Send("your-conversation-id", "proactive hello");