Python: Add Teams SDK end-to-end sample#6676
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Python end-to-end sample that hosts an Agent Framework “weather” agent as a Microsoft Teams bot using the Teams SDK (teams.py), demonstrating streaming responses and multi-turn session memory in a Teams chat surface.
Changes:
- Introduces a new Teams bot sample (
teams-agent) implemented as a PEP 723 single-file script. - Adds setup/run documentation and a configuration template for local testing via dev tunnels.
- Demonstrates Teams UI affordances (suggested actions, AI-generated label, feedback buttons) after streaming completes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| python/samples/05-end-to-end/teams-agent/app.py | Teams bot implementation wiring Teams SDK message handling to an Agent Framework agent with streaming. |
| python/samples/05-end-to-end/teams-agent/README.md | Local run + Teams testing instructions and configuration guidance for the sample. |
| python/samples/05-end-to-end/teams-agent/.env.example | Example environment configuration for Azure OpenAI + Teams bot credentials. |
|
|
||
| def build_agent() -> Agent: | ||
| """Create and return the agent instance with the weather tool registered.""" | ||
| # Reads AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, and AZURE_OPENAI_CHAT_COMPLETION_MODEL from the environment. |
There was a problem hiding this comment.
this won't work in all cases, when using OpenAIChatClient it first tries to see if there are oai keys, we prefer to have FoundryChatCLient with a AzureCliCredential in our samples
| # requires-python = ">=3.11" | ||
| # dependencies = [ | ||
| # "microsoft-teams-apps", | ||
| # "agent-framework-core", |
There was a problem hiding this comment.
core is included when installing openai, so we can remove this here
| # production; see samples/02-agents/tools/function_tool_with_approval.py. | ||
| @tool(approval_mode="never_require") | ||
| def get_weather( | ||
| location: Annotated[str, Field(description="The location to get the weather for.")], |
There was a problem hiding this comment.
| location: Annotated[str, Field(description="The location to get the weather for.")], | |
| location: Annotated[str, "The location to get the weather for."], |
| - [uv](https://github.com/astral-sh/uv) for fast dependency management | ||
| - [devtunnel](https://learn.microsoft.com/azure/developer/dev-tunnels/get-started?tabs=windows) for local testing | ||
| - An Azure OpenAI resource with a deployed model | ||
| - A Teams bot registration (Azure Bot) — App ID, password, and tenant |
There was a problem hiding this comment.
can we add a link to how to set this up?
Motivation & Context
This PR adds a Teams SDK end-to-end sample to demonstrate that Agent Framework agents work seamlessly across different hosting platforms. It mirrors the existing m365-agent sample but uses the Microsoft Teams SDK (teams.py) for hosting instead of the M365 Agents SDK, showing developers they can deploy agents in Teams without requiring Copilot Studio or M365 infrastructure.
Description & Review Guide
New sample at python/samples/05-end-to-end/teams-agent/ with:
app.py: Complete Teams bot implementation with streaming responses, multi-turn memory, feedback, and suggested actions
README.md: Setup and testing instructions
.env.example: Configuration template for Azure OpenAI and Teams bot credentials
Provides Teams developers a clear starting point for building AI agents in Teams
Demonstrates agent streaming, SessionState management, and Teams UI integration (feedback buttons, suggested actions)
Follows the same PEP 723 single-file sample pattern as other 05-end-to-end examples
Sample clarity and completeness for a Teams developer audience
Alignment with repo sample conventions (no extra workspace deps, proper docstrings, error handling)
README accuracy for local dev + Teams testing flow
Related Issue
This is a new example addition without a related issue.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.