https://github.com/alertua/msteamsapi
Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3
https://github.com/alertua/msteamsapi
Last synced: about 1 year ago
JSON representation
Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3
- Host: GitHub
- URL: https://github.com/alertua/msteamsapi
- Owner: ALERTua
- License: mit
- Created: 2024-07-22T06:59:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-06T15:47:34.000Z (about 1 year ago)
- Last Synced: 2025-05-06T16:12:17.155Z (about 1 year ago)
- Language: Python
- Homepage: https://pypi.org/project/msteamsapi/
- Size: 138 KB
- Stars: 8
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://stand-with-ukraine.pp.ua)
[](https://stand-with-ukraine.pp.ua)
[](https://stand-with-ukraine.pp.ua)
[](https://stand-with-ukraine.pp.ua)
# Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3
##### Repository: https://github.com/ALERTua/msteamsapi
##### PyPi: https://pypi.org/project/msteamsapi/
[](https://github.com/ALERTua/msteamsapi/actions/workflows/python-package.yml)
[](https://github.com/ALERTua/msteamsapi/actions/workflows/python-dev-package.yml)
[](https://github.com/ALERTua/msteamsapi/actions/workflows/commit.yml)
## Usage
- `pip install msteamsapi`
- Get a Workflow Webhook URL for your MSTeams non-private(!) channel using the standard template `Post to a channel when a webhook request is received`.
- Use the Webhook URL to instantiate `TeamsWebhook` class.
- Fill the `TeamsWebhook` with `AdaptiveCard`.
- Fill the `AdaptiveCard` with `Container`.
- Fill the `Container` with `FactSet`, `TextBlock`, etc.
- `send()` the `TeamsWebhook` instance.
Example from [tests/test_suite.py](tests/test_suite.py):
```python
from msteamsapi import TeamsWebhook, AdaptiveCard, Container, FactSet, ContainerStyle, TextWeight, TextSize
webhook = TeamsWebhook('your_webhook_url')
card = AdaptiveCard(title='card title', title_style=ContainerStyle.DEFAULT)
card.add_background(url="https://github.com/ALERTua/msteamsapi/raw/main/tests/background.png")
container = Container(style=ContainerStyle.DEFAULT)
card.mention('EMAIL', 'NAME', add_text_block=True)
mention_tag = card.mention('EMAIL', 'mention text')
container.add_image("image url", "image alt text")
container.add_text_block(
'multiline\n\ntext\n\nmention 1: %s' % mention_tag,
size=TextSize.DEFAULT, weight=TextWeight.DEFAULT, color="default", wrap=True
)
factset = FactSet(('fact 1', 'fact 1 value'))
factset.add_facts(('fact 2', 'fact 2 value'), ('fact 3', 'fact 3 value'))
container.add_fact_set(factset)
card.add_container(container)
for i, url in enumerate(['https://google.com/', 'https://goo.gle']):
card.add_url_button('url %s' % i, url)
webhook.add_cards(card)
webhook.send()
```
Your [contribution](CONTRIBUTING.md) is appreciated.