hey <@ULVA73B9P>, can you show me the template for...
# ask-marvin
f
hey @Marvin, can you show me the template for a webhook to pass the full body as a flow parameter ?
m
thought for 50.4 seconds
Here's a complete example of how to set up a webhook that passes the full request body as a flow parameter:
Copy code
python
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:
Copy code
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:
Copy code
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?