Hey Community!
How is it possible to use the Edit Fields (Set) to merge data from different sources (here: 1. Webhook with a “userMessage” from the body and 2. Chat Trigger.)
Depending on the order of the value from “userMessage” inside the “Edit Fields”-node - either Webhook or Chat Trigger - will be executed. In this case only the Chat Trigger is working.
When I try to use the webhook, following error is being displayed:
Referenced node is unexecuted
An expression references the node ‘When chat message received’, but it hasn’t been executed yet. Either change the expression, or re-wire your workflow to make sure that node executes first.
Appreciate and ideas on how to solve that issue!
If you need both sources to contribute data to the same flow, the cleanest approach is to:
- Have a single trigger (ideally a webhook).
- Send the entire message context from the external source (chat or frontend).
- Use conditional logic within n8n to differentiate the source.
- Avoid references to unexecuted nodes.
That is, restructure with a single trigger and separate routes with conditions. Instead of having two separate triggers (Webhook and Chat Trigger), you could:
- Use a single Webhook that accepts both types of input.
- Add logic within the flow to distinguish between webhook and chat userMessage.
1 Like
Thanks for that quick response, Erick!
Ok so would that mean:
If I had a code node to generate an UUID, based on if the user already has a session or not, and I’d send it via webhook as well, it could not be done, if the User already has one, right? I mean if I used an if-node, the UUID-node wasn’t executed and therefore not available. Does that mean I need to have duplicated code?
Being able to use unreferenced nodes as well would be way simpler, even though I’m already using JS with nullish coalesking.
1 Like
You can unify logic into a single Code node. Use a Code node to detect whether the data is coming from the webhook or the chat, and generate a UUID only if it’s missing:
const sessionId = $json.sessionId || require('uuid').v4();
return [{ json: { ...$json, sessionId } }];
This way, you don’t depend on separate nodes, and everything flows dynamically.
1 Like
Ok I get what you mean. Guess I’ll play around with that a bit.
FYI: At least I found another solution (tested with the message): Merging both nodes together, referencing to the “Merge”-node and reference to “different” objects. Example below:
Erick, thank you for taking your time and your help!
1 Like