ms-teams
Helper library to construct microsoft teams connector card messages.
This library supports building:
- Legacy Message Card
- Adaptive Message Card (Not yet supported in teams connector)
Usage
Legacy Message Card
Let's build below message card using ms-teams library.
# imports
from msteams.messagecard.fact import Fact
from msteams.messagecard.section import Section
from msteams.messagecard.card import MessageCard
# Create Activity Section
activity_section = Section()\
.activity_group(activity_image='https://www.shareicon.net/data/32x32/2016/07/16/634601_python_512x512.png',
activity_title='Description',
activity_text='Helper library to construct microsoft teams connector card messages')\
.build()
# Add activity section to the message card
message_card = MessageCard().title('ms-teams')\
.summary('Helper library to construct microsoft teams connector card messages')\
.theme_color('FF0000')\
.section(activity_section)
# Create facts
pkg_info = Section()\
.fact(Fact('URL', 'https://github.com/HarshadRanganathan/ms-teams').build())\
.fact(Fact('AUTHOR', 'Harshad Ranganathan').build())\
.build()
# Add facts to the message card and construct the message
payload = message_card.section(pkg_info).build()
Adaptive Card
You can use Card Playground to craft your adaptive cards and build your messages.
Refer Adaptive Card Schema for authoring your cards.
Let's build below adaptive card using ms-teams library.
# imports
from msteams.adaptivecard.elements.image import Image
from msteams.adaptivecard.elements.text_block import TextBlock
from msteams.adaptivecard.containers.column import Column
from msteams.adaptivecard.containers.column_set import ColumnSet
from msteams.adaptivecard.containers.container import Container
from msteams.adaptivecard.containers.fact_set import FactSet
from msteams.adaptivecard.containers.fact import Fact
from msteams.adaptivecard.card import AdaptiveCard
# Create Title using TextBlock (Displays text, allowing control over font sizes, weight, and color.)
title = TextBlock('ms-teams').separator(True).size('Medium').weight('Bolder').build()
# Create Activity Block (Image, Title, Subtitle)
activity_image = Image('https://www.shareicon.net/data/32x32/2016/07/16/634601_python_512x512.png').style('Person').size('small').build()
activity_title = TextBlock('Description').weight('Bolder').wrap(True).build()
activity_text = TextBlock('Helper library to construct microsoft teams connector card messages').spacing('None').wrap(True).build()
# Create ColumnSet which allows elements to sit side-by-side
activity_image_col = Column('auto').element(activity_image).build()
activity_text_col = Column('stretch').element(activity_title).element(activity_text).build()
activity_grp = ColumnSet().column(activity_image_col).column(activity_text_col).build()
# Create Container to group items together
header = Container().element(title).element(activity_grp).build()
# Add the container to the adaptive card
adaptive_card = AdaptiveCard().container(header)
# Add series of facts to the Container
pkg_info = Container()
basic = FactSet(separator=True)\
.fact(Fact('URL', 'https://github.com/HarshadRanganathan/ms-teams').build()) \
.fact(Fact('AUTHOR', 'Harshad Ranganathan').build()) \
.fact(Fact('LICENSE', 'MIT').build()) \
.build()
keywords = FactSet(separator=True) \
.fact(Fact('KEYWORDS', 'Microsoft Teams').build()) \
.build()
classifiers = FactSet(separator=True) \
.fact(Fact('CLASSIFIERS', 'Programming Language :: Python :: 3.7\n\n'
'License :: OSI Approved :: MIT License\n\n'
'Operating System :: OS Independent').build()) \
.build()
pkg_info.element(basic)
pkg_info.element(keywords)
pkg_info.element(classifiers)
# Build the container
body = pkg_info.build()
# Add facts container to the adaptive card and generate the payload message
payload = adaptive_card.container(body).build()
Metadata
Release files for ms-teams 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ms-teams-0.1.0.tar.gz | 6.0 kB | Without provenance | Details for ms-teams-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ms_teams-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ms_teams-0.1.0-py3-none-any.whl |
Total release size: 17.0 kB
Release files / ms-teams-0.1.0.tar.gz
| Download URL | ms-teams-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9b8c75041e7eb998634f1111bf285512736e771e513cde8566d715379c478ec
|
|
BLAKE2b-256 checksum How to use checksums |
9803fce6161bb7af9acecc482d7cce7a264bd4244cf6803598902e7eb9f45d59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / ms_teams-0.1.0-py3-none-any.whl
| Download URL | ms_teams-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
577920673fd79c374cc8db02e2c6fb9c1fefdf2c2f6d64b233eccbb3e24dd130
|
|
BLAKE2b-256 checksum How to use checksums |
7c5ccf03fb041e7be0e58363e3eba5d68cce26c8621b9e9c738fa3f1ea0ac348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for ms-teams 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.