Skip to content
Python helper library to construct microsoft teams connector card messages.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

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()
You can’t perform that action at this time.