Marco Ruta
03/17/2025, 4:20 PM{{ flow_run.state.name }}
at {{ flow_run.state.timestamp }}.
Flow ID: {{ flow_run.flow_id }}
Flow run ID: {{ flow_run.id }}
Flow run URL: {{ flow_run|ui_url }}
State message: {{ flow_run.state.message }}
now I want that my block forward this to the webhook to wich is linked, from the GUI how should I write the JSON data of the block?Marvin
03/17/2025, 4:21 PMjson
{
"subject": "Prefect flow run notification",
"body": "Flow run {{ flow.name }}/{{ flow_run.name }} observed in state `{{ flow_run.state.name }}` at {{ flow_run.state.timestamp }}. Flow ID: {{ flow_run.flow_id }} Flow run ID: {{ flow_run.id }} Flow run URL: {{ flow_run|ui_url }} State message: {{ flow_run.state.message }}"
}
3. Dynamic Templating: Ensure that your JSON payload uses the templating syntax correctly to dynamically insert the flow and run details. Prefect will replace these placeholders with actual values at runtime.
4. HTTP Method: Your webhook likely expects a POST
request with a JSON body. Make sure your block is configured to send data using the correct HTTP method.
For more detailed guidance, you can refer to the Prefect documentation on webhook triggers and blocks.
If you need further customization, consider any specific requirements of the webhook you're targeting, such as authentication headers or additional fields.Marco Ruta
03/17/2025, 4:23 PMMarvin
03/17/2025, 4:23 PMCustomWebhookNotificationBlock
is not being recognized as a valid dictionary. This typically happens when the JSON structure is not correctly formatted or when it's not being interpreted as a dictionary.
Here are a few things to check and try:
1. Ensure Proper JSON Formatting: Make sure your JSON data is properly formatted. Every key-value pair should be enclosed in double quotes, and the overall structure should be a valid JSON dictionary.
2. Directly Input as a Dictionary: When configuring the block, ensure that the JSON is input as a dictionary. If you're pasting it as a string, it might not be parsed correctly. It should look like this:
json
{
"subject": "Prefect flow run notification",
"body": "Flow run {{ flow.name }}/{{ flow_run.name }} observed in state `{{ flow_run.state.name }}` at {{ flow_run.state.timestamp }}. Flow ID: {{ flow_run.flow_id }} Flow run ID: {{ flow_run.id }} Flow run URL: {{ flow_run|ui_url }} State message: {{ flow_run.state.message }}"
}
3. Check for Hidden Characters: Sometimes, hidden characters or incorrect line breaks can cause JSON parsing issues. Make sure there are no extraneous characters.
4. Validate JSON: Use a JSON validator tool to ensure that your JSON structure is correct.
5. Review Documentation: You can refer to the Prefect documentation on blocks for more details on setting up and configuring blocks.
If you continue to experience issues, consider checking if there are any specific requirements or examples provided by the webhook service you're integrating with, as they might have additional constraints or examples.Marco Ruta
03/17/2025, 4:31 PM{{ flow_run.state.name }}
at {{ flow_run.state.timestamp }}. Flow ID: {{ flow_run.flow_id }} Flow run ID: {{ flow_run.id }} Flow run URL: {{ flow_run|ui_url }} State message: {{ flow_run.state.message }}"}Marvin
03/17/2025, 4:31 PM{{ flow_run.state.name }}
in your JSON payload. This typically indicates that the placeholder isn't being resolved correctly, possibly due to a misconfiguration or a misunderstanding of the available placeholders in Prefect.
Here's what you can check or do:
1. Verify Placeholder Usage: Ensure that the placeholders you're using are valid and available in the context of your automation or notification. Prefect uses Jinja templating for placeholders, and they should match the available attributes on the flow_run
object.
2. Check Flow Run Attributes: Make sure that flow_run.state.name
is a valid attribute path. You can verify this by checking the available attributes on the flow_run
object in the Prefect documentation or by examining a flow run object in your environment.
3. Use Prefect Documentation: Refer to the Prefect documentation on templating options to ensure that your placeholders are correctly formatted and supported.
4. Debugging: If possible, log or print the flow_run
object to inspect its attributes directly. This can help confirm whether state.name
is the correct attribute to use.
If you continue to encounter issues, consider simplifying the placeholders to isolate the problem, and ensure that the data you're trying to access is indeed available at the time of the notification.