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()

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microsoft_teams_apps-2.0.14.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microsoft_teams_apps-2.0.14-py3-none-any.whl (72.5 kB view details)

Uploaded Python 3

File details

Details for the file microsoft_teams_apps-2.0.14.tar.gz.

File metadata

  • Download URL: microsoft_teams_apps-2.0.14.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for microsoft_teams_apps-2.0.14.tar.gz
Algorithm Hash digest
SHA256 8d59a71b0da3afe44f452bf7a32f4a8768e5adf6cfc36250b9fa877b41084ff6
MD5 5df62e2f53c57bce1f4143a852bb6657
BLAKE2b-256 67830d3578e61bfbdb741507194cd643d83edd58720444cbd8f4d042f635d1cb

See more details on using hashes here.

File details

Details for the file microsoft_teams_apps-2.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 f49a6d55f7c4c58215ba2f12981c4ad1fec6084167e93b6b95bf8cc1df79339c
MD5 a13fb47996bc235082828a16b2bb205d
BLAKE2b-256 578d5066057fe30402714f1d0e96a09f49a0ed5b46ab4e5a569e8b69d6f24eca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page