Skip to main content

Microsoft Teams Apps Framework

High-level framework for building Microsoft Teams applications. Handles activity routing, authentication, and provides Microsoft Graph integration.

Features

  • Activity Routing: Decorator-based routing for different activity types
  • OAuth Integration: Built-in OAuth flow handling for user authentication
  • Microsoft Graph Integration: Type-safe Graph client access via user_graph and app_graph properties
  • Plugin System: Extensible plugin architecture for adding functionality

Basic Usage

from microsoft_teams.apps import App, ActivityContext
from microsoft_teams.api import MessageActivity

app = App()

@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
    await ctx.send(f"You said: {ctx.activity.text}")

# Start the app
await app.start()

Unauthenticated Requests

For local development only, JWT validation can be disabled explicitly:

app = App(dangerously_allow_unauthenticated_requests=True)

It can also be enabled with the DANGEROUSLY_ALLOW_UNAUTHENTICATED_REQUESTS=true environment variable. The previous skip_auth option is deprecated and remains supported for compatibility.

OAuth and Graph Integration

@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
    if ctx.is_signed_in:
        try:
            # Access user's Graph data
            me = await ctx.user_graph.me.get()
            await ctx.send(f"Hello {me.display_name}!")
        except (ValueError, RuntimeError, ImportError) as e:
            await ctx.send(f"Graph access failed: {e}")
    else:
        # Prompt user to sign in
        await ctx.sign_in()

Optional Graph Dependencies

Microsoft Graph functionality requires additional dependencies:

pip install microsoft-teams-apps[graph]

Or if using uv:

uv add microsoft-teams-apps[graph]

If Graph dependencies are not installed, user_graph and app_graph will raise an ImportError when accessed. If the user is not signed in or tokens are unavailable, they will raise ValueError.

Release files for microsoft-teams-apps 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microsoft-teams-apps 2.1.0
File Size Uploaded
microsoft_teams_apps-2.1.0.tar.gz 227.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microsoft-teams-apps 2.1.0
File Interpreter ABI Platform
microsoft_teams_apps-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size:373.8 kB

Release files / microsoft_teams_apps-2.1.0.tar.gz

Download URL microsoft_teams_apps-2.1.0.tar.gz
Size 227.9 kB
Tags Source
SHA-256 checksum
How to use checksums
899754b227a21040daf83893184d8c35e6d1e872ceda592c460ef10743cb351c
BLAKE2b-256 checksum
How to use checksums
51956a0494a18f225ff103f18fd2ed4e222366ba3c5a274586686483bbc71a61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / microsoft_teams_apps-2.1.0-py3-none-any.whl

Download URL microsoft_teams_apps-2.1.0-py3-none-any.whl
Size 145.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b5d57bf9c1503606e5c47dc8a2942b0b8971cf742b041fe9cbaf9bd756f1165
BLAKE2b-256 checksum
How to use checksums
ba9df024617897cc672075a065911f7c0feead5adfc643e48b9820ee7c949532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page