are there any plans to add webhook as an action fo...
# ask-community
b
are there any plans to add webhook as an action for automations?
m
Hello Braun! Actually webhook action already exists, but it's not exposed in UI yet. You can use this mutation to create webhook action:
Copy code
mutation {
  create_action (input: {
    config: {webhook: {
      url: ""
    }}
  }) {
    id
  }
}
And then create a hook with that action_id 👆
b
ah ok cool!
j
Quick update @Braun Reyes that I'm working on a PR with the UI version of that too.
z
Also @Braun Reyes -- I designed this API and it's actually far more powerful than our previous one, you can customize the JSON payload. This makes it a bit more work in the UI so that's a part of the delay there. Feel free to let me know if you have any questions about how to set it up.
b
I would love to know how to format the json payload
z
So it's configurable as the
payload
field during action configuration/creation. It defaults to dumping all the data from the event so that will give you a good idea what data is available from the event. You can then include any of those keys in your JSON payload using
{key}
(like Python string formatting).
I just took a look at my tests and I'm running it via GraphQL so I don't have an example I can copy-paste for you right now, but I'll try to write one up later today.
b
ok let me see if I can make sense of it
z
e.g.
Copy code
mutation {
  create_action(input: {config: {webhook: {url: "<http://test.prefect.io/>", payload: "{\"event-id\": \"{event.id}\"}"}}}) {
    id
  }
}
(It's kind of a pain to pass JSON into GraphQL)