I want to return one of the previous Node’s output. How do I do that?
N8n wraps everything under arrays and weird wrappers, simple programming stuff becomes hard because it’s unintuitive and not clear how to get the raw data we want.
I have the data, I can see them, and yet I need to use some kind of complex/unnecessary merging mechanism to merge nothing in order to achieve the end-result?
Surely, there is a simpler/straighter way to achieve that, is there not?
It is how n8n works.
A node is triggered by the incoming data, you can directly use that data. If you want to use other data you need to reference it specifically.
Might be good to do the course to get a better feeling of how it works.
There are 2 playlists on YouTube. Beginner and advance. Besides of this. If I see it right, you want to have the output of “pipedrive update org’s name…” as respond for the webhook? if you connect the webhook respond node to the node and also the other pipedrive node, it should work? Please keep in mind, n8n works from left to right, from top to bottom.
You mean I could respond earlier than I currently do?
If I connect multiple nodes to the “Respond to webhook”, what will happen?
Will it respond immediately after that node is reached? (I assume it will)
Or will it wait to execute all nodes connected to the “Respond to webhook”? I doubt so.
This might indeed work, although it’s not what I want to do in most cases, as it might make believe the webhook worked fine, but it could fail to actually update the data in Pipedrive.
Typically, if any node after “Compute new Org name” fails and the “Respond to webhook” is placed after it, then the webhook HTTP response will be 200 regardless of the error. That’s not really a good practice, as it will essentially hide the error and make it harder to debug.
So far, none of the answers provided are simple to implement.
If I just want to return a previous node’s output, I believe it’s just simpler to have my “Compute new Org name” also return a “JSON-friendly” property, and use that as JSON in “Respond to Webhook” node.
Surely the simplest solution, although I wish there would be a better way to do that.
You can connect the code node or the other nodes depending on which data you need to the “respond to webhook node” (can use split out/set data) before to just respond the ID or any other data. If there is an error in the path above the response to webhook, the workflow will stop and won’t respond // throw error 500. (like mentioned, n8n is working from left to right top to bottom).
Or, as you mentioned in your post, reference through the expression line.
Or use a merge node. There are multiple ways to use previous node data.
Can you elaborate a bit on that? I made some quick search but it’s the first time I’m hearing about it. You make it sound like it’s an important detail.
I was aware of “left to right”, that much is rather obvious.
But “top to bottom” is less obvious.
In you workflow above, do you mean the order is:
Webhook
Code
Edit Fields
HTTP Request
Respond to Webhook
I was under the belief that the step 3 and 5 would start at the same time (in parallel), but you make it sound like it won’t.
In this same scenario, what happens if I add another “Respond to Webhook” after “HTTP Request”? Will the one below be ignored then?
As for my initial issue, I went the way of the JSON (string) generated by code, much simpler.
I hope it is clear. The nodes are at the exact x position.
The best is to just play around a bit. It is important to know this, especially for more complex workflows. To be 100% correct, it is Top to Bottom, Left To Right. Like reading a book
Okay, so it is not running in parallel like I thought, but in series.
And I also guess only the first “Respond to Webhook” reached is actually useful, others won’t have any effect.
Here, the “Respond to Webhook” at the top will always be executed first, and the one below will never truly send data back to the browser. It’s essentially useless and should be removed to avoid creating misunderstandings in how this behaves.