I am building a workflow where midway through I filter an array and set an if node that if the output from the filter is not empty, then the false branch has a Respond with a Webhook response of 400 with this json hard coded.
{
“matched”: false,
“message”: “No match found”
}
When I run it through the scenario with the correct parameters and missing data (so the filter will return empty), the data correctly flows through the If node to the webhook response and the output is empty. Even though the response is hard coded, it comes out as:
[
{
}
]
@harrison, the workflow appears to me to work as per design. You are checking for an empty item in the list and you seem to have found one. As the item itself is empty ($json.isEmpty()) then there is essentially no data to pass to the next node and hence the next node (“webhook response”) does not run.
If I understood the requirements right you want to reply to webhook request when an item without a zip code is found. In that case, you might want to get rid of an empty item(s) in the list first and then search for an item that has no zip code, which should be passed over to “webhook responce” node. Also make the response node runs only once in case you have more than one item without a zip code.
Thanks for the response. The data that is coming in is querying a database and checking if that zip code is contained in the database and the workflow is performing correctly. We want to send a response to our workflow no matter the outcome.
What I do not understand how the webhook response node works.
I hard code the response body to be
{
“matched”: false,
“message”: “No match found”
}
and it ignores my harded coded body and passes through the json from the step before (which is empty)
My questions are:
Why is it ignoring my hard coded response body?
How do I choose what goes into the response body if not in the in the response body field?
Hey @harrison,
thank you for the really detailed description.
The answer for is is actually pretty simple and short. You defined to respond immediately in the Webhook node. So it is not waiting for the respond to webhook node.
As I mentioned earlier, for the node to run it has to have a non-empty item passed over to it. With “IF” node, you are testing if item is empty and if it is it goes to “Webhook Response” node. As a result, that node does not “fire” as it received an empty item.
Having said that, when “Webhook Response” node does get activated it outputs what it received, not what you provided in the JSON body manually (by design).
Here’s an example how Webhooks work. The “Set” node explicitly outputs some data and as a result “Webhook Response” node gets engaged and outputs what it received while returning the application that triggered the “Webhook” node the body specified in “Webhook Response” node (you could see it when testing it in the browser when using the webhook URL in the browser, which could be seen when running in production mode, not test).
Now, if an empty item comes in to “Webhook Response” node it does not fire as demonstrated in the next workflow. I used Code node and output an empty item.