chase albright
10/10/2025, 3:48 PMMarvin
10/10/2025, 3:48 PMNate
10/10/2025, 3:48 PMNate
10/10/2025, 3:48 PMNate
10/10/2025, 3:48 PMMarvin
10/10/2025, 4:00 PMprefect.blocks.notifications.SlackWebhook
) or the prefect-slack
integration for richer Slack API features.
- Docs: Prefect Slack integration
- Microsoft Teams: use the built-in prefect.blocks.notifications.MicrosoftTeamsWebhook
block.
- Blocks overview: Blocks in Prefect 3
What’s Cloud-only:
- No-code notification policies/automations from the UI are a Prefect Cloud feature. In OSS, you add notifications in code where you want them to fire (e.g., on failures or at the end of a flow).
Quick examples
- Create and save webhook blocks once:
from prefect.blocks.notifications import SlackWebhook, MicrosoftTeamsWebhook
SlackWebhook(url="<https://hooks.slack.com/services/XXX/YYY/ZZZ>").save("my-slack")
MicrosoftTeamsWebhook(url="<https://outlook.office.com/webhook/XXX/YYY/ZZZ>").save("my-teams")
- Use them in a flow:
from prefect import flow
from prefect.blocks.notifications import SlackWebhook, MicrosoftTeamsWebhook
@flow
def my_flow():
slack = SlackWebhook.load("my-slack")
teams = MicrosoftTeamsWebhook.load("my-teams")
try:
# your work here
...
slack.notify("Flow succeeded ✅")
teams.notify("Flow succeeded ✅")
except Exception as exc:
slack.notify(f"Flow failed ❌: {exc}")
teams.notify(f"Flow failed ❌: {exc}")
raise
- Alternative Slack option (prefect-slack):
# pip install prefect-slack
from prefect import flow
from prefect_slack.messages import send_incoming_webhook_message
@flow
def notify():
send_incoming_webhook_message(
webhook_url="<https://hooks.slack.com/services/XXX/YYY/ZZZ>",
text="Hello from Prefect!"
)
If you’d like, I can show a pattern to automatically send alerts on any flow failure/success with minimal boilerplate.chase albright
10/13/2025, 4:00 PMNate
10/13/2025, 4:01 PMbut the answer to your question is yes, make an automation
Nate
10/13/2025, 4:02 PMNate
10/13/2025, 4:02 PMchase albright
10/13/2025, 4:34 PMfrom prefect.blocks.notifications import SlackWebhook
slack_webhook_block = SlackWebhook.load("slack")
slack_webhook_block.notify("Hello from Prefect!")
it runs and triggers no problem, but when i set up throught hte UI, and say trigger an alert on any change in state for testing, it doesnt send any alerts.Nate
10/13/2025, 4:35 PMchase albright
10/13/2025, 5:14 PM