Proactive Activities
The BotBuilder proactive message flow requires storing a conversation reference.
In Teams SDK, we expose a
send method in the App class, almost identical to the one
passed into our activity handlers through our context. This method accepts a
conversation_id, so storing just that is enough!
- Diff
- BotBuilder
- Teams SDK
- from botbuilder.core import TurnContext
- from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
- from botbuilder.schema import ChannelAccount, ConversationAccount, ConversationReference
+ from microsoft.teams.apps import App
- adapter = CloudAdapter(ConfigurationBotFrameworkAuthentication(config))
+ app = App()
- conversation_reference = ConversationReference(
- service_url="...",
- bot=ChannelAccount(...),
- channel_id="msteams",
- conversation=ConversationAccount(...),
- user=ChannelAccount(...)
- )
-
- async def send_proactive(turn_context: TurnContext):
- await turn_context.send_activity("proactive hello")
-
- await adapter.continue_conversation(
- conversation_reference,
- send_proactive,
- )
+ await app.send("your-conversation-id", "proactive hello")
from botbuilder.core import TurnContext
from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
from botbuilder.schema import ChannelAccount, ConversationAccount, ConversationReference
adapter = CloudAdapter(ConfigurationBotFrameworkAuthentication(config))
conversation_reference = ConversationReference(
service_url="...",
bot=ChannelAccount(...),
channel_id="msteams",
conversation=ConversationAccount(...),
user=ChannelAccount(...)
)
async def send_proactive(turn_context: TurnContext):
await turn_context.send_activity("proactive hello")
await adapter.continue_conversation(
conversation_reference,
send_proactive
)
from microsoft.teams.apps import App
app = App()
await app.send("your-conversation-id", "proactive hello")