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:
Card Elements¶
TextBlock¶
ColumnSet¶
ColumnSet(columns=[
Column([TextBlock("Left")], width="1"),
Column([TextBlock("Right")], width="1")
])
Image¶
Table¶
from fabias.notifications.cards import Table
table = Table(
columns=["Name", "Value"],
rows=[
["Pipeline", "Daily_ETL"],
["Status", "Success"]
]
)