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.tw.martin98.com/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", 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 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.5.tar.gz (6.2 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.5-py2.py3-none-any.whl (7.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: msteamsapi-0.9.5.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11

File hashes

Hashes for msteamsapi-0.9.5.tar.gz
Algorithm Hash digest
SHA256 36c488f3ca5f55ed8ea0ccba2e1aae4de22bc03a68f9c58b3d5f37c9940620af
MD5 5988fb28954567de666ec60ea39179c1
BLAKE2b-256 098a57a6b37b8d5889a6387e402d7990fb8071514ca17cc5bbe83ad9732223cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msteamsapi-0.9.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11

File hashes

Hashes for msteamsapi-0.9.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 04aab5251b0c047d77c3c192c9b8c15e52d48de040f70d3c40cfdbeec0aca841
MD5 75e3d6604884f2b32e046411b90f6149
BLAKE2b-256 b32649ef6eda467ca2ea5089975befd88e3f710e28aed9b8511604ed6a59bd58

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