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.0a5.tar.gz (63.6 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.0a5-py3-none-any.whl (66.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 3953ad4117d8208f9b444a7a491bcf030b6721d2613fb3b1e46c45f145ea4b63
MD5 6bff718883dddb925d09cb67b3806e79
BLAKE2b-256 1626813d88ec5ccdd87ab4ca5fab7cdf4eefecd778c58725338e1f7b1cf107c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 4ade55216a9abdd204becbf9ab06c7b66e8fe19dc95c670d9edf8b4beefd6ff4
MD5 ec2398e1800812fc018a157cc8d0b163
BLAKE2b-256 055ccfddfc11a34100890c3c1dbf5791cbc3c92c78e0b0c57789d724c67080d6

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