Florian Giroud
07/08/2025, 5:40 PMMarvin
07/08/2025, 5:40 PMMarvin
07/08/2025, 5:41 PMpython
from prefect import flow
from typing import Dict
@flow
def process_webhook_data(webhook_body: Dict):
print(f"Received webhook data: {webhook_body}")
# Process your webhook data here
return webhook_body
# Deploy the flow
if __name__ == "__main__":
process_webhook_data.deploy(
name="webhook-processor",
work_pool="my-work-pool"
)
After deploying this flow, you'll need to:
1. Create a webhook in the Prefect UI (Cloud or Server)
2. Set up an automation that:
- Triggers on the webhook event
- Runs the webhook-processor
deployment
- Uses the following parameter mapping in the automation configuration:
json
{
"webhook_body": "{{ event.payload }}"
}
When the webhook receives a POST request with a JSON body, the entire payload will be passed to your flow's webhook_body
parameter.
For example, if your webhook receives this payload:
json
{
"customer": "acme",
"order_id": "12345",
"items": ["widget", "gadget"]
}
Your flow will receive the entire dictionary as the webhook_body
parameter.
You can find more details about webhook configuration in the Prefect webhooks documentation.
Remember that:
1. The webhook endpoint expects JSON-formatted data
2. The webhook URL should be kept secure and ideally associated with a service account
3. You can test the webhook using tools like curl
or Postman before integrating with your actual service
Would you like me to provide more specific details about any part of this setup?Nate
07/08/2025, 5:42 PM