Skip to main content

Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3

Project description

Stand With Ukraine Made in Ukraine Stand With Ukraine Russian Warship Go Fuck Yourself

Microsoft Teams AdaptiveCards API Wrapper for Python 2 and 3

Repository: https://github.com/ALERTua/msteamsapi
PyPi: https://pypi.org/project/msteamsapi/

Package and PyPi Upload DEV Package and TestPyPi Upload Commit Checks

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:

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


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.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

msteamsapi-0.9.4-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file msteamsapi-0.9.4.tar.gz.

File metadata

  • Download URL: msteamsapi-0.9.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.1 Linux/6.8.0-1021-azure

File hashes

Hashes for msteamsapi-0.9.4.tar.gz
Algorithm Hash digest
SHA256 8701814e1811214fb62cfa86bc94ff9a8d1efbee130c3fd5dd1b26b8314f9dd7
MD5 07fe7d14a242e3adedbef01ee442aeb9
BLAKE2b-256 49d00140d5787a64681367996a26c0bf3a1f41d1d6a87400d21a92ff35750ddd

See more details on using hashes here.

File details

Details for the file msteamsapi-0.9.4-py2.py3-none-any.whl.

File metadata

  • Download URL: msteamsapi-0.9.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.1 Linux/6.8.0-1021-azure

File hashes

Hashes for msteamsapi-0.9.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e0b5492df1c431f6ed50ae48606991059ae461cba0a560791ea0985c232a5c5
MD5 ac6bc9795a142f775afc9b282ab37f6d
BLAKE2b-256 fd3f244ff8e645c503b921328864d39a023229300bfdd6b5e206815f438b8b5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page