Skip to main content

Helper library to construct microsoft teams connector cards

Project description

Build Status


Helper library to construct microsoft teams connector card messages.

This library supports building:

  1. Legacy Message Card
  2. Adaptive Message Card (Not yet supported in teams connector)


Legacy Message Card

Let's build below message card using ms-teams library.

Message Card

# 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_text='Helper library to construct microsoft teams connector card messages')\

# Add activity section to the message card
message_card = MessageCard().title('ms-teams')\
    .summary('Helper library to construct microsoft teams connector card messages')\

# Create facts
pkg_info = Section()\
    .fact(Fact('URL', '').build())\
    .fact(Fact('AUTHOR', 'Harshad Ranganathan').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.

Adaptive Card

# 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('').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', '').build()) \
    .fact(Fact('AUTHOR', 'Harshad Ranganathan').build()) \
    .fact(Fact('LICENSE', 'MIT').build()) \

keywords = FactSet(separator=True) \
    .fact(Fact('KEYWORDS', 'Microsoft Teams').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 the container
body =

# Add facts container to the adaptive card and generate the payload message
payload = adaptive_card.container(body).build()

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

ms-teams-0.1.0.tar.gz (6.0 kB view hashes)

Uploaded source

Built Distribution

ms_teams-0.1.0-py3-none-any.whl (11.0 kB view hashes)

Uploaded py3

Supported by

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