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:

# Recommended: Using uv
uv add microsoft-teams-apps[graph]

# Alternative: Using pip
pip install 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.0a4.tar.gz (60.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.0a4-py3-none-any.whl (64.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a4.tar.gz
Algorithm Hash digest
SHA256 40511d292d3828fd3ed38ce8ab42ce297c0eb049bcb7bcde89f621bed652ab4d
MD5 7e4e76999527d25360f5ccb83262a2e4
BLAKE2b-256 70c8b870cf03ceb38e8bbad9c4a0123b6fbf1e1ae1acbd78c32b7a49afadee65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 8adbbe4bd3dc85b683482c16ca3343775c9cf3b2bfb3ed123cef5b95db04fe17
MD5 5ba3883832ceafc8883be2d374eed184
BLAKE2b-256 ea2fdc325543939173a6be40137bfbbd66439984423f3d4effb022b1f02018cc

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