PyHannes
10/01/2025, 1:40 PM@flow(name="Support Bot", persist_result=False)
def support_bot(event_data: dict): ...Marvin
10/01/2025, 1:40 PMMarvin
10/01/2025, 1:43 PM@flow(name="Support Bot", persist_result=False)
def support_bot(event_data: dict):
...
Set the Automation action’s Parameters JSON like this:
{
"event_data": {
"__prefect_kind": "jinja",
"template": "{{ event.payload }}"
}
}
Notes and tips:
- To pass the entire event object instead of just the payload:
{
"event_data": {
"__prefect_kind": "jinja",
"template": "{{ event }}"
}
}
- Access nested keys with dot notation or brackets:
{
"ticket_id": {
"__prefect_kind": "jinja",
"template": "{{ event.payload.ticket.id }}"
},
"weird_key": {
"__prefect_kind": "jinja",
"template": "{{ event.payload['nested']['weird-key'] }}"
}
}
- Don’t wrap the template in quotes—use the placeholder object as shown so Prefect can inject the raw dict.
- If your event might not include a payload, you can provide a safe default:
{
"event_data": {
"__prefect_kind": "jinja",
"template": "{{ event.payload | default({}) }}"
}
}
Docs for more detail:
- Use templates in Automations
- Chain deployments with events
If you can share a sample event payload, I can tailor the exact Parameters JSON for your case.PyHannes
10/01/2025, 1:46 PM"Error creating flow run: Validation failed for field 'event_data'. Failure reason: \"{...}}\" is not of type 'object'". This just passes the dict as string instead of objectMarvin
10/01/2025, 1:46 PMMarvin
10/01/2025, 1:49 PM{{ event.payload }} becomes a JSON-looking string, which then fails validation for a dict-typed parameter. Tracked here: Automation Action passes non-string types as strings.
Workarounds you can use right now:
1) Wrap Jinja with a JSON placeholder to force decoding into an object
This makes Prefect render the payload with Jinja, then parse it as JSON, so the parameter is a real dict.
{
"event_data": {
"__prefect_kind": "json",
"json": {
"__prefect_kind": "jinja",
"template": "{{ event.payload | tojson }}"
}
}
}
2) If only certain nested fields are needed, build the object explicitly and use JSON wrapping per field where needed
{
"event_data": {
"ticket_id": {
"__prefect_kind": "jinja",
"template": "{{ event.payload.ticket.id }}"
},
"metadata": {
"__prefect_kind": "json",
"json": {
"__prefect_kind": "jinja",
"template": "{{ event.payload.metadata | tojson }}"
}
}
}
}
3) As a last resort, loosen the parameter type and parse inside the flow
If 1) isn’t available in your workspace, accept a string-or-dict and coerce:
from typing import Any
import json
from prefect import flow
@flow(name="Support Bot", persist_result=False)
def support_bot(event_data: Any):
if isinstance(event_data, str):
event_data = json.loads(event_data)
...
References:
- Use templates in Automations
- Chain deployments with events
If you can share your Prefect version (Cloud/Server and Prefect package), I can confirm whether the JSON-wrapper approach should work in your environment and tailor the exact Parameters JSON to your payload.