{"id":27959,"library":"microsoft-teams-cards","title":"Microsoft Teams Cards","description":"A Python library for building Adaptive Cards and other card types used in Microsoft Teams bot messages. Part of the Microsoft Teams SDK (teams.py). Current version 2.0.0 (stable pre-release series v2.0.0a*). Active development with alpha releases publishing frequently.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/microsoft/teams.py/tree/main/packages/cards/src/microsoft/teams/cards","tags":["microsoft-teams","adaptive-cards","bots","messaging","python"],"install":[{"cmd":"pip install microsoft-teams-cards","lang":"bash","label":"Standard install"}],"dependencies":[],"imports":[{"note":"Namespace changed from microsoft.teams.* to microsoft_teams.* in v2.0.0a8; check your version for correct import path.","wrong":"from microsoft_teams.cards import AdaptiveCard","symbol":"AdaptiveCard","correct":"from microsoft.teams.cards import AdaptiveCard"},{"note":"Package provides CardFactory for building card attachments.","wrong":"from teams.cards import CardFactory","symbol":"CardFactory","correct":"from microsoft.teams.cards import CardFactory"}],"quickstart":{"code":"from microsoft.teams.cards import AdaptiveCard, CardFactory\n\ncard = AdaptiveCard(version='1.5')\ncard.add_text_block('Hello, Teams!')\ncard.add_submit_action('Submit', data={'key': 'value'})\n\n# Get card as attachment for bot activity\nattachment = CardFactory.adaptive_card_attachment(card)\nprint(attachment)","lang":"python","description":"Create a simple Adaptive Card and output its attachment representation."},"warnings":[{"fix":"Use `CardFactory.adaptive_card_attachment(AdaptiveCard(...))` instead of `CardFactory.adaptive_card_attachment({'type':'AdaptiveCard',...})`.","message":"Breaking change in v2.0.0a31: `CardFactory` methods like `adaptive_card_attachment()` now require explicit card object instead of dict. Update your code to pass a card instance.","severity":"breaking","affected_versions":">=2.0.0a31"},{"fix":"Replace `from microsoft.teams.cards import ...` with `from microsoft_teams.cards import ...`.","message":"The import path `microsoft.teams.cards` is deprecated as of v2.0.0a8. Use `microsoft_teams.cards` instead, but note that v2.0.0a8 still supports the old path with a warning.","severity":"deprecated","affected_versions":">=2.0.0a8"},{"fix":"Use Python 3.12 or 3.13. Check your Python version with `python --version`.","message":"Python 3.12+ only. Requires `python >=3.12, <3.15`. Installing on Python 3.11 or earlier will fail.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install version 2.0.0a8 or later with `pip install microsoft-teams-cards>=2.0.0a8`. Then import from `microsoft_teams.cards`.","cause":"Installed an older version of the package (e.g., v1.x) that used `microsoft.teams` namespace but you tried to import `microsoft_teams`.","error":"ModuleNotFoundError: No module named 'microsoft_teams'"},{"fix":"Use the class `AdaptiveCard` from `microsoft.teams.cards` (or `microsoft_teams.cards`) and populate it via methods like `add_text_block()`.","cause":"Using old-style dict-based card creation instead of the class-based API introduced in v2.0.0a31.","error":"AttributeError: module 'microsoft.teams.cards' has no attribute 'AdaptiveCard'"},{"fix":"Create an `AdaptiveCard` instance first: `card = AdaptiveCard(...)` then `CardFactory.adaptive_card_attachment(card)`.","cause":"Passing a raw dict to `CardFactory.adaptive_card_attachment()` instead of an `AdaptiveCard` instance. The factory in v2.0.0a31+ validates inputs.","error":"pydantic.error_wrappers.ValidationError: 1 validation error for AdaptiveCard ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}