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.0a20.tar.gz (77.0 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.0a20-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a20.tar.gz
Algorithm Hash digest
SHA256 b39130e01e0ba4bac70fc6f1ef3b750172945f52918b5aad1d203155c21accca
MD5 a7b3ef261d660a90f1233166e0ad4713
BLAKE2b-256 9b9f6ab2f7b1b9318b9b38eebdf5aa8eaeffea8038214ca9684638f88fedb768

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a20-py3-none-any.whl
Algorithm Hash digest
SHA256 f90ff836ad38740f0b9c51672bd7b271b2b976a74407d1a87698d149e13dc510
MD5 980d000d93254a56d1fe7f16a4100218
BLAKE2b-256 2049a5d187a170d6ce3586b64f2794b4d85919f85c7eebcc28b859a7729f6f3f

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