Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3
Project description
Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3
Repository: https://github.com/ALERTua/msteamsapi
PyPi: https://pypi.org/project/msteamsapi/
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
withAdaptiveCard
. - Fill the
AdaptiveCard
withContainer
. - Fill the
Container
withFactSet
,TextBlock
, etc. send()
theTeamsWebhook
instance.
Example from tests/test_suite.py:
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"
)
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 is appreciated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
msteamsapi-0.9.3.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file msteamsapi-0.9.3.tar.gz
.
File metadata
- Download URL: msteamsapi-0.9.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb4e321e4c79b4c332225880d7b931fa65a8a0f9a02ecfd998ea1caf32e90c3f |
|
MD5 | 1942e0aeab50c150f97d5e0a5db05a9a |
|
BLAKE2b-256 | f9864564430c1028f4bb3eb510e5ea51d6c9c55a266ba560186e2feb5aee75fe |
File details
Details for the file msteamsapi-0.9.3-py2.py3-none-any.whl
.
File metadata
- Download URL: msteamsapi-0.9.3-py2.py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9fbb11e129db315b069085e5442ffdc3787f8816bf761b359df7f4068d6a847 |
|
MD5 | 2f80e7892721aa7e7cf9b2a2ea95bf6d |
|
BLAKE2b-256 | d58eedfc77badf6de7db50ffc6f6905773c49d71666fb3131fc3eed8592d0f9d |