Rasmus Simmelkjær Berntsen
11/06/2025, 7:48 AMFlow run **{{ flow.name }}/{{ deployment.name }}** observed in state `{{ flow_run.state.name }}` at {{ flow_run.state.timestamp }}.
**Flow run Tags:** {{ flow_run.tags }}
**Flow run URL:** {{ flow_run|ui_url }}
**State message:** {{ flow_run.state.message }}
But I dont get a flow run urlMarvin
11/06/2025, 7:48 AMMarvin
11/06/2025, 7:56 AM{{ flow_run|ui_url }} — in Prefect 3.x that Jinja filter should render a clickable Flow Run URL in automation notifications.
If you’re getting an empty value, it’s usually one of these:
1) The automation wasn’t triggered by a flow run event
- If your trigger isn’t a flow-run state change (e.g., it’s a work pool or custom event), the flow_run variable won’t be present, so {{ flow_run|ui_url }} renders blank.
- Confirm your automation trigger is a Flow Run state event (e.g., “Flow run enters state Failed/Completed/etc.”).
2) Self-hosted: the UI base URL isn’t configured
- The ui_url filter needs a base UI URL. In self-hosted (OSS) environments, set PREFECT_UI_URL to your UI’s base (e.g., http://your-ui-host) in the environment where Automations run.
- Verify and set:
prefect config view --show-defaults
prefect config set PREFECT_UI_URL=<http://your-ui-host>
3) Prefect Cloud: very rare, but if blank, confirm workspace context
- On Cloud, ui_url should default to the Prefect Cloud UI and include your account/workspace automatically. If it’s still blank, please share your trigger details; we can dig deeper.
Your template looks fine. This should work:
Flow run *{{ flow.name }}/{{ deployment.name }}* observed in state `{{ flow_run.state.name }}` at {{ flow_run.state.timestamp }}.
*Flow run Tags:* {{ flow_run.tags }}
*Flow run URL:* {{ flow_run|ui_url }}
*State message:* {{ flow_run.state.message }}
Quick fallback (works anywhere): hardcode the base and append the ID
- If you’re self-hosted and still sorting settings, you can do:
Flow run URL: <https://your-ui-host/flow-runs/flow-run/{{> flow_run.id }}
Docs for reference:
- Automations overview
- Jinja filters (ui_url, ui_resource_events_url)
- Template variables you can access
If you can share:
- Whether you’re on Prefect Cloud or self-hosted
- The exact automation trigger you’re using
I can pinpoint the cause and get you the URL rendering.Rasmus Simmelkjær Berntsen
11/06/2025, 10:01 AMMarvin
11/06/2025, 10:01 AMMarvin
11/06/2025, 10:16 AMFlow run URL: {{ flow_run|ui_url }}
- If you give your artifact a key, it will also appear on the UI’s Artifacts page; you can mention the key in the message for easy lookup.
- Send the artifact content from your flow code
- After creating the artifact, send a Teams message directly from your flow using the Microsoft Teams block:
from prefect import flow
from prefect.artifacts import create_markdown_artifact
from prefect.blocks.notifications import MicrosoftTeamsWebhook
@flow
def my_flow():
content = "# Run report\n- metric_a: 42"
create_markdown_artifact(key="run-report", markdown=content)
teams = MicrosoftTeamsWebhook.load("my-teams-block")
teams.send(f"Run report:\n\n{content}")
- This bypasses automations and guarantees the artifact content is included.
- Use a webhook action that fetches artifact(s) and posts them
- In Automations, choose “Call a webhook” and point it at a small service you control. Your service can:
1) Receive the event with flow_run.id
2) Call the Prefect REST API to fetch the latest artifact(s) for that flow run
3) Post a nicely formatted message (with the artifact content) to Teams/Slack
- Docs for artifacts API and concepts:
- Artifacts concepts
- Create and manage artifacts
- Artifacts REST API
If you share whether you’re on Cloud or self-hosted and whether you want a link vs. full content in Teams, I can outline the exact steps (and example payloads) for the approach that fits best.