Merge Node Output Question

Describe the problem/error/question

I thought I understood the Merge node but clearly, I do not.

A. Could someone explain why my expectation (below) and the result are so different?
AND
B. How I can combine the two Edit Set nodes to get my expected result?

Setup:
1, The output from two Edit Set nodes are fed into a Merge node set to Append.
2. The Merge node flows to an Edit Set node.

  1. If I manually enter the items from the Merge node, both items are recognized. i.e. {{ $input.all()[0].json.emailAddress }} and {{ $inputt.all()[1].json.copywrite }}

  2. If I drag & drop the items from the Merge node, only Input 1 is recognized. Input 2 is [undefined].

  3. I am expecting the output from the Edit Set node that is connected to the output of the Merge node to be:

[
{
“emailAddresses”: "[email protected], [email protected],
“copywrite”: “Valerio Minato”
}
]

Instead I get:
[
{
“emailAddresses”: “[email protected], [email protected]\nValerio Minato\[email protected], [email protected]\n”,
“copywrite”: null
},
{
“emailAddresses”: “[email protected], [email protected]\nValerio Minato\n\nValerio Minato”,
“copywrite”: “Valerio Minato”
}
]

What is the error message (if any)?

The error is: [undefined]

Please share your workflow

Image of workflow:

Image of Edit Set node after the Merge node:

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

{
“nodes”: [
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “45a10e05-a148-4cee-98ca-b4e163aa1864”,
“name”: “emailAddresses”,
“value”: “[email protected], [email protected]”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-320,
-120
],
“id”: “b8266e1c-73e7-4041-ba31-27de565287ff”,
“name”: “Email List”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “0c690619-d5d0-4c08-a942-2eff7c117b8a”,
“name”: “copywrite”,
“value”: “Valerio Minato”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-320,
120
],
“id”: “b8ed50ad-41a0-4213-8762-f247034bb29e”,
“name”: “Message”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-660,
-20
],
“id”: “6da84b4e-0aea-426b-ba09-6dd405735693”,
“name”: “When clicking ‘Test workflow’”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.merge”,
“typeVersion”: 3,
“position”: [
-60,
0
],
“id”: “5a35f6a8-d3d5-4a7f-bc4f-c7f78bc03680”,
“name”: “Merge”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “262f7184-f489-478a-8db4-a563e618da2c”,
“name”: “emailAddresses”,
“value”: “={{ $input.all()[0].json.emailAddresses }}\n{{ $input.all()[1].json.copywrite }}\n{{ $json.emailAddresses }}\n{{ $json.copywrite }}”,
“type”: “string”
},
{
“id”: “08cb8d4a-0a0c-47d0-b1f3-9ad04a95f402”,
“name”: “copywrite”,
“value”: “={{ $json.copywrite }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
160,
0
],
“id”: “2e2614e1-87d8-4504-8c79-b12ff8e24b3d”,
“name”: “Errors”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “b55d8561-236e-44dc-a035-26ac2d40c8c7”,
“name”: “copywrite”,
“value”: “={{ $input.all()[0].json.copywrite }}\n{{ $json.copywrite }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
160,
180
],
“id”: “f4b18446-a46c-4090-acf7-16955eafca54”,
“name”: “This Works - 01”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “e6b77f62-ad4c-4d6d-a473-d7d31899bd5b”,
“name”: “emailAddresses”,
“value”: “={{ $input.all()[0].json.emailAddresses }}\n{{ $json.emailAddresses }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
160,
-180
],
“id”: “0677a2de-f21c-4d76-ab69-fee80d3525b4”,
“name”: “This Works - 02”
}
],
“connections”: {
“Email List”: {
“main”: [
[
{
“node”: “Merge”,
“type”: “main”,
“index”: 0
},
{
“node”: “This Works - 02”,
“type”: “main”,
“index”: 0
}
]
]
},
“Message”: {
“main”: [
[
{
“node”: “Merge”,
“type”: “main”,
“index”: 1
},
{
“node”: “This Works - 01”,
“type”: “main”,
“index”: 0
}
]
]
},
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Email List”,
“type”: “main”,
“index”: 0
},
{
“node”: “Message”,
“type”: “main”,
“index”: 0
}
]
]
},
“Merge”: {
“main”: [
[
{
“node”: “Errors”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“Email List”: [
{
“emailAddresses”: “[email protected], [email protected]
}
],
“Message”: [
{
“copywrite”: “Valerio Minato”
}
]
},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “bf55062cf7ddcdbf8e25875dbbbcd6b2d37792514cd66a0c31333838808e382c”
}
}

Share the output returned by the last node

See the images above.

Information on your n8n setup

  • n8n version: 1.81.4
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system: Ubuntu

@HenryPuppet You should set the parameters as blew:


If this help you solve this issue,please mark it as a solution.

2 Likes

Alex,

Thank you. This gives me my expected output! I need to do some research into the Merge node though, I don’t understand why this works.

Thank you for taking the time to help me. I will mark this as solved. :hugs:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.