PyMSTeams is a Python library designed to format messages and post them to Microsoft Teams via webhooks. It simplifies the creation of rich Connector Cards with text, sections, facts, images, and actions. The current version is 0.2.5, and it has an active but irregular release cadence, with updates typically addressing minor bugs, dependency bumps, or new features.
pip install pymsteamsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic Teams message with a title and a section, and send it using a webhook URL. The webhook URL is retrieved from an environment variable for security.
Implement `try-except pymsteams.TeamsWebhookException` around your `send()` calls and ensure your message content is within size limits. Consider breaking large messages into multiple cards.
Be aware that a successful `send()` call might now reflect status codes other than 200. If strict 200 OK validation is required, you can manually check `myTeamsMessage.last_http_response.status_code` after `send()`.
Ensure your Python environment is running version 3.9 or higher before installing or using `pymsteams`.