{"id":34070349,"url":"https://github.com/dennis6p/adaptive-cards-py","last_synced_at":"2025-12-14T07:06:37.804Z","repository":{"id":155347382,"uuid":"628372394","full_name":"dennis6p/adaptive-cards-py","owner":"dennis6p","description":"A user-friendly python library for building adaptive cards easily on code level ","archived":false,"fork":false,"pushed_at":"2025-12-05T08:56:50.000Z","size":387,"stargazers_count":60,"open_issues_count":4,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-08T17:33:17.148Z","etag":null,"topics":["adaptive-cards","adaptivecards","bot","message","python","ui"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dennis6p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-15T18:35:48.000Z","updated_at":"2025-12-05T08:56:53.000Z","dependencies_parsed_at":"2024-10-25T09:06:58.647Z","dependency_job_id":"b12f618f-322b-407e-84aa-9b6adfaa645e","html_url":"https://github.com/dennis6p/adaptive-cards-py","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/dennis6p/adaptive-cards-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dennis6p%2Fadaptive-cards-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dennis6p%2Fadaptive-cards-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dennis6p%2Fadaptive-cards-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dennis6p%2Fadaptive-cards-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dennis6p","download_url":"https://codeload.github.com/dennis6p/adaptive-cards-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dennis6p%2Fadaptive-cards-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27720878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-14T02:00:11.348Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adaptive-cards","adaptivecards","bot","message","python","ui"],"created_at":"2025-12-14T07:06:35.167Z","updated_at":"2025-12-14T07:06:37.790Z","avatar_url":"https://github.com/dennis6p.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adaptive Cards \u003c!-- no toc --\u003e \n\n- [Adaptive Cards ](#adaptive-cards-)\n  - [About](#about)\n  - [Features](#features)\n  - [Dependencies](#dependencies)\n  - [Installation](#installation)\n  - [Library structure](#library-structure)\n  - [Usage](#usage)\n    - [Create a card](#create-a-card)\n      - [A simple card](#a-simple-card)\n      - [A more complex card](#a-more-complex-card)\n    - [Update card components](#update-card-components)\n    - [Validate a card](#validate-a-card)\n    - [Send card to MS Teams](#send-card-to-ms-teams)\n  - [Examples](#examples)\n  - [Feature Roadmap](#feature-roadmap)\n  - [Contribution](#contribution)\n  - [Glossary](#glossary)\n\n[![PyPI version](https://badge.fury.io/py/adaptive-cards-py.svg)](https://pypi.org/project/adaptive-cards-py/)\n\nA thin Python wrapper for creating [**Adaptive Cards**](https://adaptivecards.io/) easily on code level. The deep integration of Python's `typing` package alongside the famous `pydantic` library prevents you from creating invalid schemas and guides you while setting up the code for generating visually appealing cards.\n\nIf you are interested in the general concepts of adaptive cards and want to dig a bit deeper, have a look into the [**official documentation**](https://learn.microsoft.com/en-us/adaptive-cards/) or get used to the [**schema**](https://adaptivecards.io/explorer/) first.\n\n💡 **Please note**\n\u003cbr\u003eThis library is work in progress. Missing parts are planned to be added from time to time.\n\n## ⚠️ Disclaimer\n\nThis library is covering the open source stream for [**adaptive cards**](https://adaptivecards.io/). In the meantime, there is a [**parallel stream for some Microsoft products**](https://adaptivecards.microsoft.com/) specifically, which offers a bigger variety of elements. Along with that, a Python SDK has been provided and is under development. So, if you want to use adaptive cards with MS Teams, Bot Frameworks or MS Outlook, you might also want to checkout the [**Microsoft-backed library**](https://learn.microsoft.com/en-us/microsoftteams/platform/teams-ai-library/in-depth-guides/adaptive-cards/overview?pivots=python).\n\n## About\n\nThis library is intended to provide a clear and simple interface for creating adaptive cards with only a few lines of code in a more robust way. The heavy usage of Python's `typing` mechanisms and the `pydantic` library should prevent one from creating invalid schemes and structures. Instead, creating and sending cards should be intuitive and supported by the typing system.\n\nFor a comprehensive introduction into the main ideas and patterns of adaptive cards, head over to the [**official documentation**](https://docs.microsoft.com/en-us/adaptive-cards). I also recommend using the [**schema explorer**](https://adaptivecards.io/explorer) page alongside the implementation, since the library's type system relies on these schemas.\n\nFurther resources can be found here:\n\n* [__Format cards in Teams__](https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cdesktop1%2Cdesktop2%2Cconnector-html)\n* [__Official repository__](https://github.com/microsoft/AdaptiveCards)\n\n💡 **Please note**\n\u003cbr\u003e There are size limitations related to the [__target framework__](https://learn.microsoft.com/en-us/adaptive-cards/resources/partners#live) (or \"__Host__\") a card is supposed to be used with. As of now, the maximum card size can be __28KB__ when used with Webhooks in Teams ([__Format cards in Teams__](https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cdesktop1%2Cdesktop2%2Cconnector-html)). For bot frameworks the upper limit is set to __40KB__ ([__Format your bot messages__](https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/format-your-bot-messages)). An corresponding check is part of the [`CardValidator`](#validate-schema).\n\n## Features\n\n💡 **Please note**\n\u003cbr\u003eIt's highly recommended to turn on the **type check** capabilities for Python in your editor. This will serve you with direct feedback about the structures you create. If you are trying to assign values of incompatible types, your editor will mark it as such and yell at you right in the moment you are about to do so. Otherwise, invalid schemas can be detected by making use of the card validation, once the card has been successfully created. Cards are validated against the official schema there and possible incompatibilities can be detected.\n\n**Key aspects**\n\n+ Type annotated components based on `pydantic` and `typing`\n+ Validation of versions, card size and schema\n+ Simple `json` and `dict` export\n+ Update methods for manipulating card components after creation\n+ [**Passive error handling**](https://github.com/rustedpy/result) via the `result` package for validation and card updates (similar to Rust approach) \n+ Compliant with the official structures and ideas\n+ Communication via `TeamsClient`\n\n## Dependencies\n\n* `pydantic`\n* `requests`\n* `jsonschema`\n* `mypy`\n* `result`\n\nWorks with Python 3.10+\n\n## Installation\n\n```bash\npip install adaptive-cards-py\n```\nor \n```bash\nuv add adaptive-cards-py\n```\n\n## Library structure\n\n**Adaptive cards** can consist of different kinds of components. The four main categories beside the actual cards are **Elements**, **Containers**, **Actions** and **Inputs**. You can find all available components for each category within the corresponding module. The `AdaptiveCard` is defined in the `cards` module.\n\nIn addition to that, some fields of certain components are of custom types. These types are living inside the `card_types` module. For instance, if you are about to assign a color to a `TextBlock`, the field `color` will only accept a value of type `Colors`, which is implemented in the aforementioned Python file.\n\nTo perform validation on a fully initialized card, one can make use of the `CardValidator` class (`validation` module). Similar to the whole library, this class provides a simple interface. For creating a validator, a factory (`CardValidatorFactory`) can be used, in order to account for the desired target framework. Validation will check the following points:\n\n\n* Are any components used, which are not yet available for the card version?\n* Is the card size within the limitation defined by the target framework?\n* Does the schema correspond to the official card schema?\n* Are there any components in the card body at all?\n\n## Usage\n\n### Create a card\n\n#### A simple card\n\nA simple `TextBlock` lives in the `elements` module and can be used after it's import.\n\n```Python\nfrom adaptive_cards.elements import TextBlock\n\ntext_block: TextBlock = TextBlock(text=\"It's your first card\")\n```\nFor this component, `text` is the only required property. However, if more customization is needed, further available fields can be used.\n\n```Python\nfrom adaptive_cards.elements import TextBlock\nimport adaptive_cards.card_types as types\n\ntext_block: TextBlock = TextBlock(\n    text=\"It's your second card\",\n    color=types.Colors.ACCENT,\n    size=types.FontSize.EXTRA_LARGE,\n    horizontal_alignment=types.HorizontalAlignment.CENTER,\n)\n```\n\nAn actual card with only this component can be created like this.\n\n```Python\nfrom adaptive_cards.card import AdaptiveCard\n\n...\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_item(text_block) \\\n                                 .create()\n```\n\nFind your final layout below.\n\n![simple card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card.jpg?raw=true)\n\n💡 **Please note**\n\u003cbr\u003eAfter building the object is done, the `create(...)` method must be called in order to construct the final object. In this case, the object will be of type `AdaptiveCard`.\n\nTo directly export your result, make use of the\n`to_json()` method provided by every card.\n\n```Python\nwith open(\"path/to/out/file.json\", \"w+\") as f:\n    f.write(card.to_json())\n\n```\n\nAssuming you have a bunch of components you want your card to enrich with. There is also a method for doing so. Let's re-use the example from before, but add another `Image` component here as well.\n\n```Python\nfrom adaptive_cards.elements import TextBlock, Image\nimport adaptive_cards.card_types as types\n\ntext_block: TextBlock = TextBlock(\n    text=\"It's your third card\",\n    color=types.Colors.ACCENT,\n    size=types.FontSize.EXTRA_LARGE,\n    horizontal_alignment=types.HorizontalAlignment.CENTER,\n)\n\nimage: Image = Image(url=\"https://adaptivecards.io/content/bf-logo.png\")\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_items([text_block, image]) \\\n                                 .create()\n\n# Alternatively, you can also chain multiple add_item(...) functions:\n# card = AdaptiveCard.new() \\\n#                    .version(version) \\\n#                    .add_item(text_block) \\\n#                    .add_item(image) \\\n#                    .create()\n\n\nwith open(\"path/to/out/file.json\", \"w+\") as f:\n    f.write(card.to_json())\n```\n\nThis will result in a card like shown below.\n\n![simple card 2](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/simple_card/simple_card_2.jpg?raw=true)\n\n#### A more complex card\n\nYou can have a look on the following example for getting an idea of what's actually possible with adaptive cards.\n\n![wrap up card](https://github.com/dennis6p/adaptive-cards-py/blob/main/examples/wrap_up_card/wrap_up_card.jpg?raw=true)\n\n\u003cdetails\u003e\n\u003csummary\u003eCode\u003c/summary\u003e\n\n```python\nimport adaptive_cards.card_types as types\nfrom adaptive_cards.actions import ActionToggleVisibility, TargetElement\nfrom adaptive_cards.validation import SchemaValidator\nfrom adaptive_cards.card import AdaptiveCard\nfrom adaptive_cards.elements import TextBlock, Image\nfrom adaptive_cards.containers import Container, ContainerTypes, ColumnSet, Column\nfrom result import Result, Ok, Err, is_ok\n\ncontainers: list[ContainerTypes] = []\n\nicon_source: str = \"https://icons8.com/icon/vNXFqyQtOSbb/launch\"\nicon_url: str = \"https://img.icons8.com/3d-fluency/94/launched-rocket.png\"\n\nheader_column_set: ColumnSet = ColumnSet(\n    columns=[\n        Column(\n            items=[\n                TextBlock(text=\"Your Daily Wrap-Up\", size=types.FontSize.EXTRA_LARGE)\n            ],\n            width=\"stretch\",\n        ),\n        Column(items=[Image(url=icon_url, width=\"40px\")], rtl=True, width=\"auto\"),\n    ]\n)\ncontainers.append(\n    Container(\n        items=[header_column_set], style=types.ContainerStyle.EMPHASIS, bleed=True\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=\"**Some numbers for you**\",\n                size=types.FontSize.MEDIUM,\n            ),\n            ColumnSet(\n                columns=[\n                    Column(\n                        items=[\n                            TextBlock(text=\"_Total_\"),\n                            TextBlock(text=\"_Done by you_\"),\n                            TextBlock(text=\"_Done by other teams_\"),\n                            TextBlock(text=\"_Still open_\"),\n                            TextBlock(text=\"_Closed_\"),\n                        ]\n                    ),\n                    Column(\n                        items=[\n                            TextBlock(text=\"5\"),\n                            TextBlock(text=\"4\"),\n                            TextBlock(text=\"3\"),\n                            TextBlock(text=\"6\"),\n                            TextBlock(text=\"1\"),\n                        ],\n                        spacing=types.Spacing.MEDIUM,\n                        rtl=True,\n                    ),\n                ],\n                separator=True,\n            ),\n        ],\n        spacing=types.Spacing.MEDIUM,\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=\"**Detailed Results**\",\n                size=types.FontSize.MEDIUM,\n            ),\n        ],\n        separator=True,\n        spacing=types.Spacing.EXTRA_LARGE,\n    )\n)\n\nsample_column_set: ColumnSet = ColumnSet(\n    columns=[\n        Column(items=[TextBlock(text=\"12312\")]),\n        Column(items=[TextBlock(text=\"done\", color=types.Colors.GOOD)]),\n        Column(items=[TextBlock(text=\"abc\")]),\n        Column(\n            items=[\n                Image(\n                    url=\"https://adaptivecards.io/content/down.png\",\n                    width=\"20px\",\n                    horizontal_alignment=types.HorizontalAlignment.RIGHT,\n                )\n            ],\n            select_action=ActionToggleVisibility(\n                title=\"More\",\n                target_elements=[\n                    TargetElement(\n                        element_id=\"toggle-me\",\n                    )\n                ],\n            ),\n        ),\n    ]\n)\n\ncontainers.append(\n    Container(\n        items=[\n            Container(\n                items=[\n                    ColumnSet(\n                        columns=[\n                            Column(items=[TextBlock(text=\"**Number**\")]),\n                            Column(items=[TextBlock(text=\"**Status**\")]),\n                            Column(items=[TextBlock(text=\"**Topic**\")]),\n                            Column(items=[TextBlock(text=\"\")]),\n                        ],\n                        id=\"headline\",\n                    ),\n                ],\n                style=types.ContainerStyle.EMPHASIS,\n                bleed=True,\n            ),\n            Container(items=[sample_column_set]),\n            Container(\n                items=[\n                    TextBlock(\n                        text=\"_Here you gonna find more information about the whole topic_\",\n                        id=\"toggle-me\",\n                        is_visible=False,\n                        is_subtle=True,\n                        wrap=True,\n                    )\n                ]\n            ),\n        ],\n    )\n)\n\ncontainers.append(\n    Container(\n        items=[\n            TextBlock(\n                text=f\"Icon used from: {icon_source}\",\n                size=types.FontSize.SMALL,\n                horizontal_alignment=types.HorizontalAlignment.CENTER,\n                is_subtle=True,\n            )\n        ]\n    )\n)\n\ncard = AdaptiveCard.new().version(\"1.5\").add_items(containers).create()\n\nvalidator: SchemaValidator = SchemaValidator()\nresult: Result[None, str] = validator.validate(card)\n\nprint(f\"Validation was successful: {is_ok(result)}\")\n\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSchema\u003c/summary\u003e\n\n```json\n{\n    \"type\": \"AdaptiveCard\",\n    \"version\": \"1.5\",\n    \"schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n    \"body\": [\n        {\n            \"items\": [\n                {\n                    \"type\": \"ColumnSet\",\n                    \"columns\": [\n                        {\n                            \"items\": [\n                                {\n                                    \"text\": \"Your Daily Wrap-Up\",\n                                    \"type\": \"TextBlock\",\n                                    \"size\": \"extraLarge\"\n                                }\n                            ],\n                            \"width\": \"stretch\"\n                        },\n                        {\n                            \"items\": [\n                                {\n                                    \"url\": \"https://img.icons8.com/3d-fluency/94/launched-rocket.png\",\n                                    \"type\": \"Image\",\n                                    \"width\": \"40px\"\n                                }\n                            ],\n                            \"rtl\": true,\n                            \"width\": \"auto\"\n                        }\n                    ]\n                }\n            ],\n            \"type\": \"Container\",\n            \"style\": \"emphasis\",\n            \"bleed\": true\n        },\n        {\n            \"spacing\": \"medium\",\n            \"items\": [\n                {\n                    \"text\": \"**Some numbers for you**\",\n                    \"type\": \"TextBlock\",\n                    \"size\": \"medium\"\n                },\n                {\n                    \"separator\": true,\n                    \"type\": \"ColumnSet\",\n                    \"columns\": [\n                        {\n                            \"items\": [\n                                {\n                                    \"text\": \"_Total_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Done by you_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Done by other teams_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Still open_\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"_Closed_\",\n                                    \"type\": \"TextBlock\"\n                                }\n                            ]\n                        },\n                        {\n                            \"spacing\": \"medium\",\n                            \"items\": [\n                                {\n                                    \"text\": \"5\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"4\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"3\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"6\",\n                                    \"type\": \"TextBlock\"\n                                },\n                                {\n                                    \"text\": \"1\",\n                                    \"type\": \"TextBlock\"\n                                }\n                            ],\n                            \"rtl\": true\n                        }\n                    ]\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"separator\": true,\n            \"spacing\": \"extraLarge\",\n            \"items\": [\n                {\n                    \"text\": \"**Detailed Results**\",\n                    \"type\": \"TextBlock\",\n                    \"size\": \"medium\"\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"items\": [\n                {\n                    \"items\": [\n                        {\n                            \"id\": \"headline\",\n                            \"type\": \"ColumnSet\",\n                            \"columns\": [\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Number**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Status**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"**Topic**\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                }\n                            ]\n                        }\n                    ],\n                    \"type\": \"Container\",\n                    \"style\": \"emphasis\",\n                    \"bleed\": true\n                },\n                {\n                    \"items\": [\n                        {\n                            \"type\": \"ColumnSet\",\n                            \"columns\": [\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"12312\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"done\",\n                                            \"type\": \"TextBlock\",\n                                            \"color\": \"good\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"text\": \"abc\",\n                                            \"type\": \"TextBlock\"\n                                        }\n                                    ]\n                                },\n                                {\n                                    \"items\": [\n                                        {\n                                            \"url\": \"https://adaptivecards.io/content/down.png\",\n                                            \"type\": \"Image\",\n                                            \"horizontalAlignment\": \"right\",\n                                            \"width\": \"20px\"\n                                        }\n                                    ],\n                                    \"selectAction\": {\n                                        \"title\": \"More\",\n                                        \"targetElements\": [\n                                            {\n                                                \"elementId\": \"toggle-me\"\n                                            }\n                                        ],\n                                        \"type\": \"Action.ToggleVisibility\"\n                                    }\n                                }\n                            ]\n                        }\n                    ],\n                    \"type\": \"Container\"\n                },\n                {\n                    \"items\": [\n                        {\n                            \"id\": \"toggle-me\",\n                            \"isVisible\": false,\n                            \"text\": \"_Here you gonna find more information about the whole topic_\",\n                            \"type\": \"TextBlock\",\n                            \"isSubtle\": true,\n                            \"wrap\": true\n                        }\n                    ],\n                    \"type\": \"Container\"\n                }\n            ],\n            \"type\": \"Container\"\n        },\n        {\n            \"items\": [\n                {\n                    \"text\": \"Icon used from: https://icons8.com/icon/vNXFqyQtOSbb/launch\",\n                    \"type\": \"TextBlock\",\n                    \"horizontalAlignment\": \"center\",\n                    \"isSubtle\": true,\n                    \"size\": \"small\"\n                }\n            ],\n            \"type\": \"Container\"\n        }\n    ]\n}\n```\n\n\u003c/details\u003e\n\n### Update card components\n\nUpdating components and their fields can be done in-place via the `update_item(...)`/`update_action(...)` methods executed on a card object. Please note, that this is only possible for components which got assigned a proper `id` and have been part of the **initial** card setup. IDs for components added to the layout via the update method are not tracked. Hence, updating these components won't have any effect!\n\n```python\nimport adaptive_cards.card_types as types\nfrom adaptive_cards.actions import ActionOpenUrl\nfrom adaptive_cards.card import AdaptiveCard\nfrom adaptive_cards.elements import TextBlock\n\ntext_block: TextBlock = TextBlock(\n    id=\"text-id\",\n    text=\"Initial text\",\n)\n\naction_open_url: ActionOpenUrl = ActionOpenUrl(\n    id=\"action-id\", url=\"any-url\", title=\"title\"\n)\n\n# build card\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new().add_item(text_block).create()\n\n# update card\ncard.update_item(\n    id=\"text-id\",\n    text=\"New text\",\n    horizontal_alignment=types.HorizontalAlignment.CENTER,\n)\ncard.update_action(id=\"action-id\", url=\"new-url\")\n```\n\nUpdates will **only succeed** if the following three conditions are fulfilled:\n- ID of an component has been set when the card was created initially\n- The property about to be updated must be part of the actual data model of the parent component\n- The property's type must match the defined type in the parent data model\n\nProperties do not need to be set initially to be updated via the above described steps.\n\n### Validate a card\n\nNew components and properties are getting introduced every now and then. This means, if you are using an early version for a card and add properties, which are not compliant with it, you will have an invalid schema. To prevent you from exporting properties not yet supported by the card and target framework, a card validation can be performed for the expected [__target framework__](https://learn.microsoft.com/en-us/adaptive-cards/resources/partners#live) (see [__Library structure__](#library-structure) for more info). For MS Teams as the target framework, it would look like this:\n\n```python\nfrom adaptive_cards.card import AdaptiveCard\nfrom adaptive_cards.validation import (\n    CardValidatorFactory, \n    CardValidator,\n    Finding\n)\nfrom result import Result, Err, Ok, is_ok\n\n...\n\nversion: str = \"1.4\"\ncard: AdaptiveCard = AdaptiveCard.new() \\\n                                 .version(version) \\\n                                 .add_items([text_block, image]) \\\n                                 .create()\n\n# generate a validator object for your required target framework\nvalidator: CardValidator = CardValidatorFactory.create_validator_microsoft_teams()\nresult: Result[None, str] = validator.validate(card)\n\nprint(f\"Validation was successful: {is_ok(result)}\")\n\n# As it might come in handy in some situations, there is a separate class method\n# which can be utilized to calculate the card size without running the full\n# validation procedure\ncard_size: float = validator.card_size(card)\nprint(card_size)\n\n# in case the validation failed, you can check the validation details by using the according method, \n# to get a full list of all findings occurred during validation.\ndetails: list[Finding] = validator.details()\n\n# please note, that the validation details are stored within the validator and will be overwritten,\n# once a new validator.validation(card) execution is done with the same validator object. \n\n```\n\n### Send card to MS Teams\n\nOf course, you want to create those cards for a reason. So once you did that, you might want to send it to one of the compatible services like MS Teams. See the following example, how this can be done, assuming that all previously mentioned steps are done prior to that:\n\n```python\n\n...\n\nfrom adaptive_cards.client import TeamsClient\nfrom requests import Response\n\n...\n\n# send card\nwebhook_url: str = \"YOUR-URL\"\nclient: TeamsClient = TeamsClient(webhook_url)\nresponse: Response = client.send(card)\n\nnew_webhook_url: str = \"YOUR-URL-OF-SECOND-CHANNEL\"\nclient.set_webhook_url(new_webhook_url)\nresponse: Response = client.send(card)\n\n...\n\n```\n\nSo far, there is only a MS Teams client available. If further services should be supported, give me some feedback by opening an Issue for instance.\n\nFind further information about sending cards or creating Webhooks to/in MS Teams [__here__](https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498).\n\n## Examples\n\nIf you are interested in more comprehensive examples or the actual source code, have a look into the [**`examples`**](examples) folder.\n\n## Feature Roadmap\n\n* [x] Add size check to schema validation\n* [x] Add proper schema validation\n* [x] Add further target framework validators\n* [x] Update card components after creation\n* [ ] Allow reading of json-like schemas\n\n## Contribution\n\nFeel free to create issues, fork the repository or even come up with a pull request. I am happy about any kind of contribution and would love\nto hear your feedback or ideas for enhancement!\n\n## Glossary\n\n* **Item**: Any object of type *container*, *element* or *input*\n* **Action**: Any object of type *action* \n* **Component**: Synonym for both actions and items\n* **Property**: A specific attribute a component comes with. Defined via the [**official schema**](https://adaptivecards.io/explorer/). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdennis6p%2Fadaptive-cards-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdennis6p%2Fadaptive-cards-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdennis6p%2Fadaptive-cards-py/lists"}