Skip to main content

The app package for a Microsoft Teams agent

Project description

[!CAUTION] This project is in active development and not ready for production use. It has not been publicly announced yet.

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.0a1.tar.gz (55.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.0a1-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 bac4ec8856c277ecf05f580f7bd70a0a2fa2852f7d6d37b660aee9f42ca7060d
MD5 14d539050b07802a388707c6612b969d
BLAKE2b-256 fb17c525a0193aab90edd94cbc7b12eb251c3a6e50d8214b55eb2190981fdaea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for microsoft_teams_apps-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9c6038053353860de77e42a690f81bd2349b3d5a5e3f24c81a60c882f6ed1c3
MD5 fcec085f38ca3a6632d36771e2954c0e
BLAKE2b-256 4360f35aa91cd141bddcc91116fffd47b61f0436092237c0668de90561735d08

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