Skip to content

Python: Add Teams SDK end-to-end sample#6676

Open
MehakBindra wants to merge 5 commits into
microsoft:mainfrom
MehakBindra:feature/teams-sdk-sample
Open

Python: Add Teams SDK end-to-end sample#6676
MehakBindra wants to merge 5 commits into
microsoft:mainfrom
MehakBindra:feature/teams-sdk-sample

Conversation

@MehakBindra

@MehakBindra MehakBindra commented Jun 22, 2026

Copy link
Copy Markdown
Member

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

  • What are the major changes?

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

  • What is the impact of these changes?

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

  • What do you want reviewers to focus on?

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

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings June 22, 2026 23:33
@moonbox3 moonbox3 added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jun 22, 2026
@github-actions github-actions Bot changed the title Add Teams SDK end-to-end sample Python: Add Teams SDK end-to-end sample Jun 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread python/samples/05-end-to-end/teams-agent/app.py
Comment thread python/samples/05-end-to-end/teams-agent/app.py
Comment thread python/samples/05-end-to-end/teams-agent/app.py Outdated
Comment thread python/samples/05-end-to-end/teams-agent/README.md
Comment thread python/samples/05-end-to-end/teams-agent/README.md Outdated
Comment thread python/samples/05-end-to-end/teams-agent/README.md
Comment thread python/samples/05-end-to-end/teams-agent/.env.example

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.")],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a link to how to set this up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants