pymsteams
A Python wrapper for sending Connector Card messages to Microsoft Teams webhooks.
Repository Health
Technical Analysis
pymsteams is a Python library for formatting and posting messages to Microsoft Teams via incoming webhook (Connector Card) URLs. You create a connector card object with your channel’s webhook URL, add text and optional structured sections, and call send to deliver the message.
Beyond simple text, pymsteams lets you compose rich Connector Cards with titles, colored themes, multiple sections, facts, images, and potential-action buttons. It also offers an optional async client for sending messages inside an event loop, making it a convenient bridge between Python applications and Teams channels for alerts and notifications.
What You Get
- A connectorcard object for composing and sending Teams messages from a webhook URL
- Rich card construction with title, theme color, text, and multiple sections
- Section building blocks including facts, images, and activity metadata
- PotentialAction buttons for links and interactive card actions
- An optional async client for sending messages within an event loop
Common Use Cases
- Sending alert and monitoring notifications to a Teams channel
- Posting CI/CD build and deployment status updates to Teams
- Delivering formatted operational or business messages from Python jobs
Under The Hood
Architecture - The library is implemented in a single module, src/pymsteams/__init__.py (~285 lines). It centers on a connectorcard class that accumulates a MessageCard JSON payload through fluent setter methods (title, text, color, addSection, addPotentialAction), with helper classes cardsection and potentialaction composing the nested structures. Calling send() POSTs the assembled JSON to the configured webhook URL via requests, and an async variant mirrors the same builder for asyncio use.
Tech Stack - Pure Python packaged with pyproject.toml and uv lockfiles. The core dependency is requests for HTTP, with an optional async extra pulling in an async HTTP client for the non-blocking sender.
Code Quality - A tests/ directory covers card construction and message sending. The surface area is small and the payload-builder pattern is easy to follow, though the project’s README explicitly notes it is looking for maintainers, so upkeep is currently limited.
API Design - The developer experience is approachable and fluent: construct a card with a URL, chain a few descriptive methods, and call send(). The naming maps directly onto Microsoft’s Connector Card concepts, which keeps the learning curve low for anyone familiar with Teams webhooks.