Microsoft 365 Extensions
Microsoft 365 Extensions let you extend an existing Teams SDK application to channels such as Direct Line and Email without rewriting any Teams-specific capabilities.
Register your existing Teams SDK handlers on the App returned by useTeamsSdk (TypeScript), use_teams_sdk (Python), or AddTeamsSdk (C#).
Microsoft 365 Extensions work with your existing Teams SDK configuration and handlers.
This app is a bridge where Microsoft Agents SDK AgentApplication acts the multichannel host.
Matching Teams activities continue through your Teams SDK handlers, while non-Teams activities and unmatched Teams activities flow through the Agents SDK application.
How to Use It
Install the Microsoft 365 Extensions package alongside the Microsoft Agents SDK:
pip install microsoft-agents-activity microsoft-agents-authentication-msal microsoft-agents-hosting-aiohttp microsoft-agents-hosting-core microsoft-teams-m365extensions
Add an Agents SDK host to your existing Teams SDK application, then replace your current App initialization with use_teams_sdk:
from os import environ
from microsoft_agents.activity import load_configuration_from_env
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.hosting.core import AgentApplication, MemoryStorage, TurnState
from microsoft_agents.hosting.core.app import ApplicationOptions
from microsoft_teams.m365extensions import use_teams_sdk
agents_sdk_config = load_configuration_from_env(dict(environ))
connection_manager = MsalConnectionManager(**agents_sdk_config)
adapter = CloudAdapter(connection_manager=connection_manager)
agent_app = AgentApplication[TurnState](
options=ApplicationOptions(storage=MemoryStorage(), adapter=adapter),
connection_manager=connection_manager,
**agents_sdk_config,
)
app = use_teams_sdk(agent_app, connection_manager)
Key Benefits
Extend Your Teams App to Other Channels
Through this extension, you can connect your existing Teams SDK app to other channels such as Direct Line and Email without rewriting your Teams-specific logic.
| Activity | Route |
|---|---|
| Teams activity matching a Teams SDK handler | Teams SDK |
| Teams activity without a matching Teams SDK handler | Agents SDK |
| Direct Line / Direct Line activity | Agents SDK |
| Email activity | Agents SDK |
Example Message Handler
You can use the Agents SDK message handler to identify the incoming channel and confirm how each activity was routed.
The incoming activity is recognized as Teams if the channelId="msteams".
@AGENT_SDK_APP.message(_command("channel"))
async def _channel(context: TurnContext, _state: TurnState):
via = (
"Teams turn with no matching teams.py route → fell through"
if is_teams_channel(context.activity)
else "non-Teams channel → passed straight through"
)
await context.send_activity(f"[Agent SDK] channelId={context.activity.channel_id} ({via})")
Direct Line

Email

Access Rich Teams Capabilities from Agents SDK
When an Agents SDK handler receives a Teams activity, it can use the Teams SDK API client to access Teams-specific capabilities, such as message reactions:
import asyncio
import re
from microsoft_agents.hosting.core import TurnContext, TurnState
from microsoft_teams.api.clients.api_client import ApiClient
from microsoft_teams.m365extensions import is_teams_channel
@agent_app.message(re.compile(r"^agents sdk react$", re.IGNORECASE))
async def agents_sdk_reaction(context: TurnContext, _state: TurnState):
if not is_teams_channel(context.activity):
await context.send_activity(
"Message reactions are only available in Teams."
)
return
response = await context.send_activity("Adding then removing a reaction.")
api = ApiClient(
service_url=context.activity.service_url,
options=app.api.http,
)
conversation_id = context.activity.conversation.id
await api.conversations.add_reaction(conversation_id, response.id, "like")
await asyncio.sleep(2)
await api.conversations.delete_reaction(conversation_id, response.id, "like")
For a full example, the Python Microsoft 365 Extensions sample demonstrates a single application running across Teams, Web Chat, and Email.
How It Works
Microsoft 365 Extensions adds a lightweight middleware bridge to your existing Teams SDK application. Aside from app initialization, your Teams-specific code stays the same.
- Add the bridge. Call
useTeamsSdk(TypeScript),use_teams_sdk(Python), orAddTeamsSdk(C#) to connect your app to Agents SDK. - Keep your Teams logic. Existing handlers and API client calls continue handling Teams activities.
- Add more channels. Direct Line, Email, and unmatched Teams activities flow to the Agents SDK.