https://prefect.io logo
d

David Migl

07/12/2023, 10:10 PM
Hello Everyone , I am trying to create a prefect automation to send a custom payload via a webhook. Is this possible ? More details in thread:
Currently we are sending an email notification with the body as as follows:
Copy code
"title": {{ 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 }}
I would instead like to send a payload where the keys , i.e:
Copy code
{
  "title": ... ,
  "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 }}
}
Appreciate anyone taking the time to read and/or respond to this
t

Tim-Oliver

07/14/2023, 2:50 PM
I am also struggling with that. What happens with the stuff in "body"? Will this become the content of
--data
if I would submit the request via curl?
d

David Migl

07/20/2023, 9:07 PM
Hey yall, I found this issue and corresponding PR(which was merged to master) related to the question I asked. but im not seeing it in the cloud UI. https://github.com/PrefectHQ/prefect/issues/9526. Does someone mind confirming whether or not this functionality is possible to achieve in the cloud UI?
@Tim-Oliver, not sure if you ever got your question answered but the body becomes a
"message": "<body value here>"
as part of a payload
j

Jake Kaplan

07/21/2023, 2:40 PM
hey, you should be able to describe the body sent to your webhook when you're creaing the automation:
d

David Migl

07/21/2023, 4:43 PM
Hi @Jake Kaplan, First thanks for your reply! Understood. I guess my question was more just wondering why we could not send a custom payload -- after digging around in the prefect repo i found this PR which was merged to master (which demonstrates sending a custom payload):

https://user-images.githubusercontent.com/20429502/237680520-47b08fc0-16a9-4900-a8fa-4fda43b52a0d.png

j

Jake Kaplan

07/21/2023, 5:18 PM
ah, do you mean if you wanted to send custom content as opposed to json?
d

David Migl

07/21/2023, 5:21 PM
I guess so, instead of sending out a singular key-vaule pair like so:
"message": <body>
I would like to send a payload like:
Copy code
"flow_name": "{{flow.name}}" ,
...
etc etc..
And that PR that i found seems to do just that, but the cloud UI does not seem to have that functionality
j

Jake Kaplan

07/21/2023, 10:08 PM
Ah I see what you mean! Notifications are slightly different between cloud and the self hosted. That one looks to be a user contribtion. I don’t think there is a particular reason we couldn’t support that (at least off the top of my head) in cloud. Would you mind opening a feature request issue for cloud in the prefect github repo
👍 1
t

Tim-Oliver

07/24/2023, 2:04 PM
I would like to log some info to airtable via webhook. From the airtable documentation I found the following to work with `curl`:
Copy code
curl -X POST <https://api.airtable.com/v0/XXXXXXXXXX/webhook-test> \ 
  -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
  -H "Content-Type: application/json" \
  --data '{
  "records": [
    {
      "fields": {
"Name": "Tim"
}
    },
    {
      "fields": {
"Name": "Oliver"
}
    }
  ]
}'
As far as I could follow along, this is currently not possible with the cloud UI. I think this would be super useful 🙂
d

David Migl

07/24/2023, 3:41 PM
Hey Jake , Thanks for looking into this for me. Feature request will be created.