Nicholas Tang
10/29/2025, 3:56 PMMarvin
10/29/2025, 3:56 PMMarvin
10/29/2025, 4:02 PMfrom prefect.blocks.notifications import MicrosoftTeamsWebhook
# Replace with your saved block name
teams = MicrosoftTeamsWebhook.load("my-teams-block")
# Send a simple test message
teams.notify(
body="Test message from Prefect",
subject="Prefect → Teams test"
)
You should see a card appear in the Teams channel within a few seconds. If not:
- Double-check the webhook URL is valid and current
- Try creating a brand new Incoming Webhook connector in Teams and paste that URL into a new Prefect block
- Keep the body simple (plain text) for the test
Helpful CLI checks:
prefect block ls
prefect block inspect microsoft-teams-webhook/my-teams-block
Docs:
- Blocks overview
- Notifications block API
- CLI: prefect block
2) Validate the Automation setup
- Trigger: For flow failures, it should match the event type prefect.flow-run.Failed.
- Scope: Ensure the resource selector matches your flow/deployment (if you scoped it narrowly, it may not match).
- Action: “Send a notification” → MicrosoftTeamsWebhook → points to the correct block name you tested above.
- Enabled: Make sure the automation is toggled on.
What to check in the UI:
- Events: Confirm you see prefect.flow-run.Failed events when your flows fail.
- Automation → Activity/Recent runs: You should see events that matched and whether the action ran successfully. If there was a problem delivering the notification (e.g., invalid URL or a 4xx/5xx), it will usually be shown here.
Docs:
- Creating Automations
- Event triggers
- States and failure events
3) Network and org-policy nuances
- For Prefect Cloud Automations, notifications are sent from Prefect Cloud (not your worker), so your own egress typically isn’t involved. Teams Incoming Webhook endpoints are public; if your org restricts connectors or requires specific allowlists, that can silently block messages.
- If you’re self-hosting Prefect Server and using Automations there, ensure the server can reach the exact host in your webhook URL (often something like company.webhook.office.com). Allow outbound HTTPS to that host.
4) Common pitfalls we see
- Using a rotated/old webhook URL in the Prefect block after reconfiguring in Teams.
- Trigger not matching your events (wrong event type or resource scope).
- Automation disabled, or pointing to a different block than the one you updated.
- Org policy disabled Incoming Webhooks in Teams.
- Very large or unusual message templates; keep the content small/simple to test.
If you’d like, share:
- Whether you’re on Cloud or self-hosted
- Your Prefect version
- A screenshot of the Automation “Activity” view (or the exact error shown there)Marvin
10/29/2025, 4:02 PMSeb
10/30/2025, 7:42 AM