Skip to content

Microsoft Teams

Setup

from fabias.notifications import teams
from fabias import ServicePrincipalAuth

auth = ServicePrincipalAuth(
    tenant_id="your-tenant-id",
    client_id="your-client-id",
    client_secret="your-client-secret"
)

teams.client(
    team_id="your-team-guid",
    channel_id="your-channel-guid",
    auth=auth
)

Sending Messages

from fabias.notifications import teams

# Simple message
teams.send("Hello from fabias!")

# With subject
teams.send("Pipeline completed successfully", subject="ETL Status")

Using Channels

# Get a channel object
channel = teams.channel("other-channel-guid")

# Send multiple messages
channel.send("First message")
channel.send("Second message")

Adaptive Cards

from fabias.notifications.cards import Adaptive, TextBlock, ColumnSet, Column, Image

card = Adaptive(body=[
    ColumnSet(columns=[
        Column([
            Image("https://example.com/logo.png", size="small")
        ], width="auto"),
        Column([
            TextBlock("Alert!", weight="Bolder", size="Large"),
            TextBlock("Pipeline completed successfully")
        ])
    ])
])

teams.send(card)

Webhook URLs

You can also send directly to a webhook:

teams.send(
    "Message content",
    webhook_url="https://outlook.office.com/webhook/..."
)

Card Elements

TextBlock

TextBlock("Hello", weight="Bolder", size="Large", color="Accent")

ColumnSet

ColumnSet(columns=[
    Column([TextBlock("Left")], width="1"),
    Column([TextBlock("Right")], width="1")
])

Image

Image("https://example.com/image.png", size="medium", altText="Description")

Table

from fabias.notifications.cards import Table

table = Table(
    columns=["Name", "Value"],
    rows=[
        ["Pipeline", "Daily_ETL"],
        ["Status", "Success"]
    ]
)

Actions

from fabias.notifications.cards import ActionOpenUrl, ActionShowCard

ActionOpenUrl("View Details", url="https://example.com")
ActionShowCard("Show More", card=Adaptive(body=[TextBlock("More info")]))