Skip to main content

Microsoft Teams adapter for chat-py

Project description

chat-adapter-teams

Microsoft Teams adapter for chat-py. Python port of upstream packages/adapter-teams.

Talks to the Bot Framework REST API directly via httpx + msal. Upstream uses @microsoft/teams.apps; no stable Python equivalent exists, so the adapter is implemented against the REST surface.

Install

uv add chat-py chat-py-adapter-teams chat-py-adapter-state-redis

Auth / config

TeamsAdapterConfig supports three auth modes:

Mode Fields Env var fallbacks
Client secret appId + appPassword TEAMS_APP_ID, TEAMS_APP_PASSWORD, TEAMS_APP_TENANT_ID
Federated identity federated (workload identity / managed ID) TEAMS_APP_ID, TEAMS_APP_TENANT_ID
Certificate (PEM) certificatenot implemented; raises ValidationError

Additional config: appType ("MultiTenant" or "SingleTenant"), dialogOpenTimeoutMs, apiUrl.

Minimal example

from chat import Chat
from chat_adapter_teams import create_teams_adapter
from chat_adapter_state_redis import create_redis_state

bot = Chat(
    user_name="mybot",
    adapters={"teams": create_teams_adapter()},  # reads TEAMS_APP_ID etc.
    state=create_redis_state(url="redis://localhost:6379"),
)


@bot.on_new_message
async def reply(thread, message):
    await thread.post("Received.")

Mount bot.handle_webhook("teams", body, headers) under /api/webhooks/teams. The webhook handler verifies Bot Framework-signed JWTs via verify_bearer_token.

Thread ID

Teams thread IDs: teams:{base64(conversationId)}:{base64(serviceUrl)}.

Parity notes

  • JWT verification uses the same JWKS + issuer allowlist as upstream.
  • Adaptive Card translation (card_to_adaptive_card) targets the same schema as upstream's converter.
  • TeamsFormatConverter produces the same markdown↔mdast output.
  • Known gaps (v0.1.0 — raises NotImplementedError):
    • Microsoft Graph API conversation reader (read_thread)
    • Certificate-based auth (certificate config field)
  • Live event dispatch (@microsoft/teams.apps) is not ported; handle_webhook is a JWT-verifying shim. Full dispatch lands with the async Adapter protocol in core.

Test

uv run pytest packages/chat-adapter-teams

# Live — requires an app registration
TEAMS_APP_ID=... TEAMS_APP_PASSWORD=... uv run pytest packages/chat-integration-tests -k teams

Upstream

https://github.com/vercel/chat/tree/main/packages/adapter-teams

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chat_py_adapter_teams-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file chat_py_adapter_teams-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chat_py_adapter_teams-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chat_py_adapter_teams-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f646a08609bf424f3d9adcb04ccd50a7328eda7ad3b94314f1cf6b75f311bc91
MD5 1553eb1ba8715e5607417e0febde2b48
BLAKE2b-256 328e21f4c5ce6487a069ccdcbb86e2db81dad3289c85bd91f4a3690b1078097e

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