Hassan Hashmi
04/29/2026, 4:13 PMMarvin
04/29/2026, 4:13 PMMarvin
04/29/2026, 4:14 PM`
from datetime import timedelta
from prefect import flow
from prefect._experimental.sla.objects import LatenessSla
@flow
def my_flow():
pass
my_flow.from_source(
source="<https://github.com/owner/repo>",
entrypoint="flows.py:my_flow",
).deploy(
name="my-deployment",
work_pool_name="my-pool",
_sla=[
LatenessSla(
name="late-by-5-minutes",
within=timedelta(minutes=5),
severity="high",
)
],
)
`
#### 2) Create a Slack webhook block in the UI
In Prefect Cloud:
- Go to Blocks
- Create a Slack Webhook block
- Paste your Slack incoming webhook URL
- Save it
#### 3) Create the automation in the UI
In Prefect Cloud:
- Go to Automations
- Click New Automation
- Choose an Event trigger
- Set the event to:
- prefect.sla.violation
Then add an action:
- Send notification
- Select your Slack Webhook block
Example message:
- Subject: Flow run late: {{ event.resource.name }}
- Body: A flow run exceeded the 5-minute lateness SLA.
### If you want to do this fully from the UI only
You can create the Slack block and the automation in the UI, but the lateness SLA itself is typically defined on the deployment.
### Important clarification
If you literally mean task lateness:
- Prefect does not provide this as a standard UI lateness notification feature for task runs
- The built-in lateness/SLA path is for flow runs
### Helpful docs
- Automations
- Notifications
- SLAs
- Prefect Cloud
If you want, I can also show you:
- a pure UI walkthrough step-by-step, or
- how to alert on flow run state instead if “lateness” isn’t quite what you need.Hassan Hashmi
04/29/2026, 4:23 PMHassan Hashmi
04/29/2026, 4:24 PMMarvin
04/29/2026, 4:24 PMMarvin
04/29/2026, 4:24 PMHassan Hashmi
04/29/2026, 4:30 PMMarvin
04/29/2026, 4:30 PMMarvin
04/29/2026, 4:30 PM`
This is a test notification from Prefect.
Flow: {{ flow.name }}
Deployment: {{ deployment.name }}
Status: {{ deployment.status }}
URL: {{ deployment|ui_url }}
`
And subject:
`
Test notification: {{ flow.name }}/{{ deployment.name }}
`
### Important warning
Those template variables only work if the trigger provides them.
If your automation is not a deployment-status event, flow.name, deployment.name, or deployment.status may not render.
### Safer generic test template
If you just want to confirm Slack delivery, use a more generic event-based template:
Subject
`
Prefect notification test
`
Body
`
This is a test notification from Prefect.
Event: {{ event.event }}
Resource: {{ event.resource.name }}
Occurred: {{ event.occurred }}
`
That is usually safer for automations driven by events.
### For SLA/lateness notifications
If your trigger is based on lateness / SLA violation, use something more like:
Subject
`
Flow run late: {{ event.resource.name }}
`
Body
`
A Prefect SLA violation was detected.
Flow run: {{ event.resource.name }}
Event: {{ event.event }}
Occurred: {{ event.occurred }}
`
### Recommendation
If your goal is just testing the Slack webhook block, use plain text with minimal templating first:
Subject
`
Prefect Slack test
`
Body
`
Hello from Prefect. This is a test notification.
`
If that works, then switch to templated fields.
If you want, I can help you build the exact subject/body for your specific automation trigger type.