{"id":1653,"library":"pymsteams","title":"PyMSTeams","description":"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.","status":"active","version":"0.2.5","language":"en","source_language":"en","source_url":"https://github.com/rveachkc/pymsteams","tags":["microsoft teams","messaging","notifications","webhook","chatops"],"install":[{"cmd":"pip install pymsteams","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP POST requests to Microsoft Teams webhooks.","package":"requests"}],"imports":[{"note":"The primary class 'Teams' is accessed as an attribute of the imported 'pymsteams' module.","symbol":"Teams","correct":"import pymsteams\nconnector = pymsteams.Teams(webhook_url)"}],"quickstart":{"code":"import pymsteams\nimport os\n\n# Get your Microsoft Teams webhook URL from an environment variable\n# Example: https://outlook.office.com/webhook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/IncomingWebhook/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\nwebhook_url = os.environ.get('TEAMS_WEBHOOK_URL', '')\n\nif not webhook_url:\n    print(\"Error: TEAMS_WEBHOOK_URL environment variable not set.\")\nelse:\n    myTeamsMessage = pymsteams.Teams(webhook_url)\n    myTeamsMessage.text(\"Hello, Teams! This is a test message from PyMSTeams.\")\n    myTeamsMessage.title(\"PyMSTeams Quickstart Alert\")\n    myTeamsMessage.addSection(\n        pymsteams.cardsection()\n        .addFact(\"Status\", \"Success\")\n        .addFact(\"Environment\", \"Production\")\n        .addFact(\"Timestamp\", \"2024-04-09 10:30:00\")\n    )\n    try:\n        myTeamsMessage.send()\n        print(\"Message sent successfully!\")\n    except Exception as e:\n        print(f\"Failed to send message: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Sending messages exceeding the Microsoft Teams API size limit (typically 28KB per card) will now raise a `TeamsWebhookException`.","severity":"breaking","affected_versions":">=0.1.14"},{"fix":"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()`.","message":"The `send()` method's success validation was relaxed in recent versions. Previously, it strictly checked for HTTP 200 OK. Now, it validates on any 2xx HTTP status code (e.g., 202 Accepted).","severity":"gotcha","affected_versions":">=0.2.2"},{"fix":"Ensure your Python environment is running version 3.9 or higher before installing or using `pymsteams`.","message":"Versions 0.2.5 and higher of `pymsteams` explicitly require Python 3.9 or newer.","severity":"breaking","affected_versions":">=0.2.5"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}