gee
08/20/2025, 11:49 AMMarvin
08/20/2025, 11:49 AMMarvin
08/20/2025, 11:51 AM{
"flow_run_id": "{{ event.resource.id }}",
"flow_name": "{{ event.resource.name }}",
"state": "{{ match.state.type }}",
"occurred": "{{ event.occurred }}"
}
Workarounds:
- Send the flow_run_id and have the receiver fetch parameters from the Prefect API:
- Flow Runs API: https://docs-3.prefect.io/v3/api-ref/rest-api/
- Emit a custom event from inside your flow that contains the parameters you choose to share, then automate on that event.
- Call the external webhook from inside your flow (where you have access to get_run_context().parameters
) instead of using an Automation action.
References:
- Automations overview: https://docs-3.prefect.io/v3/concepts/automations/
- Webhooks (incoming, for context): https://docs-3.prefect.io/v3/how-to-guides/cloud/create-a-webhook
If you meant an incoming webhook that starts a flow run and you want to pass parameters into that run, that’s a different path—happy to outline it.gee
08/20/2025, 12:00 PMMarvin
08/20/2025, 12:00 PMMarvin
08/20/2025, 12:00 PM{{ flow_run.parameters[...] }}
in webhook bodies and headers.
Examples you can drop into a webhook action:
- JSON body with individual params
{
"flow_run_id": "{{ flow_run.id }}",
"flow_name": "{{ flow_run.name }}",
"state": "{{ match.state.type }}",
"user": "{{ flow_run.parameters['user'] }}",
"threshold": "{{ flow_run.parameters['config']['threshold'] }}"
}
- Safely include all parameters as a JSON blob (use tojson
so it renders valid JSON)
{
"flow_run_id": "{{ flow_run.id }}",
"params": {{ flow_run.parameters | tojson }}
}
- Header templating
X-Requester: {{ flow_run.parameters['user'] }}
Caveats:
- flow_run.parameters
is only available when the automation is triggered by a flow-run event (e.g., scheduled, running, completed, failed). If your trigger isn’t tied to a flow run, flow_run
won’t exist.
- Be mindful of sensitive/large parameters; you may not want to dump the whole set into a webhook.
Docs:
- Access parameters in templates: https://docs.prefect.io/v3/how-to-guides/automations/access-parameters-in-templates
- Automations overview: https://docs.prefect.io/v3/concepts/automations
If you share the exact parameter shape you care about, I can sketch a minimal body that won’t turn into a JSON horror show.gee
08/21/2025, 11:15 AMMarvin
08/21/2025, 11:15 AMMarvin
08/21/2025, 11:30 AMfrom prefect.blocks.notifications import CustomWebhookNotificationBlock
hook = CustomWebhookNotificationBlock(
name="my-alert",
url="<https://example.com/webhook>",
method="POST",
json_data={"text": "Hello from Prefect"}
)
hook.save("my-alert") # select this block in an Automation action
- Or use the generic Webhook block directly from a flow:
from prefect.blocks.webhook import Webhook
wh = Webhook(url="<https://example.com/webhook>", method="POST")
resp = wh.call({"message": "hello"})
print(resp.status_code, resp.text)
Inbound (receive webhooks into Prefect)
- Prefect generates the URL for you; you don’t choose it. In Cloud: Events → Webhooks → New Webhook. Copy the generated URL into your external system so it can POST to Prefect. Then wire that webhook to an Automation that takes action (e.g., run a deployment).
- Docs: Create a webhook (inbound)
If you can share which direction you’re implementing (outbound vs inbound) and whether you’re using the UI or code, I can give exact, step-by-step instructions.gee
08/21/2025, 11:53 AMMarvin
08/21/2025, 11:53 AMMarvin
08/21/2025, 11:55 AMContent-Type: application/json
- In the Body field, write a JSON template and insert the parameters.
Examples
1) Full JSON body with parameters embedded
{
"flow_run_id": "{{ event.resource.id }}",
"deployment": "{{ event.resource.name }}",
"parameters": {{ parameters | tojson }}
}
2) Safer fallback if parameters might be missing (e.g., if the trigger isn’t a flow-run event)
{
"flow_run_id": "{{ event.resource.id }}",
"parameters": {{ (parameters | default({})) | tojson }}
}
3) Build the entire body via Jinja and serialize once
{{ {
"flow_run_id": event.resource.id,
"deployment": event.resource.name,
"parameters": parameters | default({})
} | tojson }}
Notes
- The automation template context includes the triggering event
and, for flow-run events, a parameters
dict you can reference directly.
- Use | tojson
to ensure the parameters dict is rendered as valid JSON.
- Make sure your Automation trigger is a flow-run/deployment event type that actually has parameters; otherwise, use the default({})
pattern shown.
Docs
- Accessing parameters in templates: Access parameters in templates
- Webhooks concept: Webhooks
If you share the exact event you’re triggering on and the payload shape you need, I can tailor the exact template.