Skip to main content

The app package for a Microsoft Teams agent

Project description

[!CAUTION] This project is in public preview. We’ll do our best to maintain compatibility, but there may be breaking changes in upcoming releases.

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.

Project details


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.0a78.tar.gz (85.2 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.0a78-py3-none-any.whl (70.3 kB view details)

Uploaded Python 3

File details

Details for the file microsoft_teams_apps-2.0.0a78.tar.gz.

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a78.tar.gz
Algorithm Hash digest
SHA256 d2a850ea9ac65ef1df9265e80c08d122a56e74cd212ea635a214a083dafb4293
MD5 539bdb857083d9318f05a4d9886a708c
BLAKE2b-256 bd42247aac44ab70b5172646c3723e2e9ce6d66efbe70e277c02b0f7c5ce6dea

See more details on using hashes here.

File details

Details for the file microsoft_teams_apps-2.0.0a78-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a78-py3-none-any.whl
Algorithm Hash digest
SHA256 34ca61fb7033dc11463005c1dcfd6c1102e2b30544e4faa7684a1e3301ef9bcb
MD5 3a07271e04db6053f57a9e37ed40e906
BLAKE2b-256 3873888303ae12ee8b67e431a80c6dd11ac3add2a819c0372fbafac6539ad6d5

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 Pingdom Monitoring Sentry Error logging StatusPage Status page