Hello! I am trying to trigger a deployment from a ...
# ask-community
b
Hello! I am trying to trigger a deployment from a webhook event. I want to pass a parameter to my flow from the body of my webhook event. For example I have a Webhook template like this:
Copy code
{
  "event": "{{body.event_name}}",
  "resource": {
    "prefect.resource.id": "data.type.{{ body.data_type }}",
    "prefect.resource.name": "{{ body.friendly_name }}",
    "data_url": "{{ body.url }}"
  }
}
When I send a post to my webhook endpoint, I receive the event and it contains a body like this:
Copy code
"body": "{\"event_name\":\"event_add\",\"data_type\":\"event\",\"friendly_name\":\"add_new_event\",\"url\":<https://example.com/123>}"
Now when I create a new automation, I don't know how to fill in the form in the Prefect dashboard. Should the resource be the name of my webhook? For the
event_url
parameter, how can I use the value of
url
in my webhook event body?
b
Hey Ben! To get a head start on filling out the form for the automation trigger, I'd suggest going to the events page in your UI and finding the event that is produced as a result of hitting the webhook. If you click on the link present in the name of the event, it will take you to a new page with the formatted event and the raw json. There should be a little hamburger menu in the upper righthand corner. If you click that menu, there's an option for "Automate". Click that, and it'll take you to page where the trigger field for an automation is filled out on your behalf.
After that, you can configure the action which is where you'll put the url in the body as your input for the parameter. It'll look something like this
b
ok great, so in my case, it would be like this?
Copy code
{{ event.payload.body.url }}
b
To the right of your parameter on the "Action" form, there's another small hamburger menu. I believe you'll want to ensure "use Jinja input" is selected.
Yes that seems right to me!
b
ok let me give that a try, thanks!
Ok I got it, in the end, instead of using the
payload
I used the value from the webhook template which were
event.resource.data_url
thank you for the help!
b
Sweet! Glad you got it to work 🙌