Hello n8n community!
I have searched the documentation but did not find a successful answer to my problem.
The use case
I’m processing a list of customer records. Each customer has a contacts array containing items of different types (e.g. phone, email). My goal is to:
- Split the
contactsarray into individual items - Apply a different mapping depending on the contact type (e.g. phone numbers need to be parsed and reformatted, emails pass through directly)
- Re-aggregate all mapped contacts back into a single array
- Merge that array back into the original customer item to build the final payload
The workflow
The Merge (append) node works inside a loop when the Aggregate is the last node. However, adding a Merge (combine by position) after the Aggregate — which is necessary to reassemble the contacts back into the customer item — breaks the loop entirely.
Test data:
{
"data": [{
"firstName": "John",
"lastName": "Doe",
"contacts": [
{
"type": "phone",
"value": "+33652252525"
}
]
},
{
"firstName": "Mary",
"lastName": "Doe",
"contacts": [
{
"type": "email",
"value": "marydoe@example.com"
}
]
},
{
"firstName": "John",
"lastName": "Smith",
"contacts": [
{
"type": "email",
"value": "johnsmith@example.com"
},
{
"type": "phone",
"value": "+33652252526"
}
]
}]
}
Workflow
Information on your n8n setup
- n8n version: 2.20.9
- Database (default: SQLite): PostgrSQL
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
