Merge Node not properly working

Describe the problem/error/question

I have a Merge Node to verify e-mails with a tool. It’s working for some rows, but for some I don’t get the new values from Input 2, and so my workflow is not working properly in the end (I’m losing many lines).

I’m pretty stuck on what to check & how to fix it. sharing the full workflow below, but giving a short explanation here since the WF is pretty long:

"I have some steps related to verifying e-mail addresses with Zerobounce. I connect to that tool via their API.
After checking, I Rename the Keys to add “zb_status” & “zb_sub_status” on the line of the file. Then, I set the values on the line with: zb_status = {{ $json.zb_status }}, zb_sub_status = {{ $json.zb_sub_status }} , & Email = {{ $json.address }}.

After that, I have a Merge node that it’s bugging (= it appears as it’s not taking all of the zb_status & zb_sub_status information):
It’s a Combine & Merge by Fields node.
As Input Fields 1 and 2 I have Email, and the Output Type is to Enrich Input 1.

Please share your workflow

{
  "meta": {
    "instanceId": "81a6941fb453731dcece0c54e92c6a2270feae43cadf0ab3b7899f3f01564c7d"
  },
  "nodes": [
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"Email\"]}}",
              "operation": "contains",
              "value2": "=@"
            }
          ]
        }
      },
      "name": "IF no email1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        12700,
        3000
      ],
      "id": "8ba94c96-3ab4-4393-8db7-e5fa79399bc2"
    },
    {
      "parameters": {
        "authentication": "queryAuth",
        "url": "=https://api.zerobounce.net/v2/validate",
        "options": {
          "batchInterval": 200,
          "batchSize": 1
        },
        "queryParametersUi": {
          "parameter": [
            {
              "name": "email",
              "value": "={{$json[\"Email\"]}}"
            },
            {
              "name": "ip_address"
            }
          ]
        }
      },
      "name": "Zerobounce email validation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        12740,
        3660
      ],
      "id": "6030be27-01ab-4fa5-b3ae-e26482d83e70",
      "retryOnFail": true,
      "waitBetweenTries": 5000,
      "credentials": {
        "httpQueryAuth": {
          "id": "10",
          "name": "Query Auth account 2"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"zb_status\"]}}",
              "value2": "valid"
            },
            {
              "value1": "={{$json[\"zb_status\"]}}",
              "value2": "catch-all"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "IF email is Valid",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        13920,
        3640
      ],
      "id": "3e283248-016c-4881-8fca-d46b7b9a907c"
    },
    {
      "parameters": {
        "keys": {
          "key": [
            {
              "currentKey": "status",
              "newKey": "zb_status"
            },
            {
              "currentKey": "sub_status",
              "newKey": "zb_sub_status"
            }
          ]
        },
        "additionalOptions": {}
      },
      "name": "Rename Keys",
      "type": "n8n-nodes-base.renameKeys",
      "typeVersion": 1,
      "position": [
        12920,
        3660
      ],
      "id": "b7549202-4f14-4a10-91dd-00bd25dd7026"
    },
    {
      "parameters": {
        "mode": "combine",
        "mergeByFields": {
          "values": [
            {
              "field1": "Email",
              "field2": "Email"
            }
          ]
        },
        "joinMode": "enrichInput1",
        "options": {}
      },
      "id": "b31ec60e-5ef8-47e6-ab96-d02a79b8fda1",
      "name": "Merge2",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        13720,
        3640
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "zb_status",
              "value": "={{ $json.zb_status }}"
            },
            {
              "name": "zb_sub_status",
              "value": "={{ $json.zb_sub_status }}"
            },
            {
              "name": "Email",
              "value": "={{ $json.address }}"
            }
          ]
        },
        "options": {}
      },
      "id": "7864f214-50a4-4d3e-a522-7365de86cde7",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        13080,
        3660
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.Email }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "id": "f0aef703-9a67-489a-94ed-1d64b62f0589",
      "name": "Email is not empty",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        14240,
        3040
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1tHzym1OVNjCN3gneLZ_Xgp6igkFY3Q2ZvWxfsLre5JI/edit#gid=317796169",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "317796169",
          "mode": "id"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "isDuplicate",
              "displayName": "isDuplicate",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedin_profile__c",
              "displayName": "linkedin_profile__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company",
              "displayName": "Company",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "FirstName",
              "displayName": "FirstName",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LastName",
              "displayName": "LastName",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date_Sent_SDR__c",
              "displayName": "Date_Sent_SDR__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "RecordTypeId",
              "displayName": "RecordTypeId",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LeadSource",
              "displayName": "LeadSource",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LeadSourceCampaignName__c",
              "displayName": "LeadSourceCampaignName__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country_Code__c",
              "displayName": "Country_Code__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nombre_d_employ_s__c",
              "displayName": "Nombre_d_employ_s__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "NumberOfEmployees",
              "displayName": "NumberOfEmployees",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "insee_activiteprincipaleunitelegale__c",
              "displayName": "insee_activiteprincipaleunitelegale__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "insee_codepostaletablissement__c",
              "displayName": "insee_codepostaletablissement__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Siret__c",
              "displayName": "Siret__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments__c",
              "displayName": "Comments__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zb_status",
              "displayName": "zb_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "zb_sub_status",
              "displayName": "zb_sub_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Legal_Form",
              "displayName": "Legal_Form",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedin_company_id__c",
              "displayName": "linkedin_company_id__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "personarank",
              "displayName": "personarank",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Founded_Year__c",
              "displayName": "Founded_Year__c",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "displayName": "City",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "PostalCode",
              "displayName": "PostalCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "AnnualRevenue",
              "displayName": "AnnualRevenue",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "4150229d-49f5-44b1-b9ca-57810cfb4074",
      "name": "No/Invalid Email Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        14740,
        3220
      ],
      "retryOnFail": true,
      "waitBetweenTries": 5000,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "hdAQwhBQlxBWl2tK",
          "name": "Google Julia Solias Account"
        }
      }
    }
  ],
  "connections": {
    "IF no email1": {
      "main": [
        [
          {
            "node": "Zerobounce email validation",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No/Invalid Email Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zerobounce email validation": {
      "main": [
        [
          {
            "node": "Rename Keys",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF email is Valid": {
      "main": [
        [
          {
            "node": "Email is not empty",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No/Invalid Email Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rename Keys": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "IF email is Valid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Email is not empty": {
      "main": [
        null,
        [
          {
            "node": "No/Invalid Email Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}```

## Information on your n8n setup
- **n8n version:** [email protected]

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

hello @Julia_Solias_Huelamo

Can you share the output of both Zerobounce and the node before the first IF (with anonymous data ofc)?

Hello @barn4k thanks a lot for taking a look :slight_smile:

For the TRUE branch, here’s an example (I updated the values with “x” to make it anonymous :pray::

[
  {
    "Siret__c": xx,
    "NumberOfEmployees": 392,
    "Company": "X",
    "FirstName": "E",
    "LastName": "T",
    "Email": "[email protected]",
    "Phone": "+44 1883 734914",
    "isMobile": "=IF(AND(iserror(FIND(\"+33 6\",INDIRECT(CONCATENATE(\"F\",ROW())))),iserror(FIND(\"+33 7\",INDIRECT(CONCATENATE(\"F\",ROW()))))),\"standard\",\"mobile\")",
    "Comments__c": "",
    "Industry": "Software Development",
    "Nombre_d_employ_s__c": "100 +",
    "linkedin_profile__c": "https://www.linkedin.com/in/xxx",
    "Title": "Ceo",
    "Website": "xxx.com",
    "Date_Sent_SDR__c": "2/26/2024",
    "RecordTypeId": "xx",
    "LeadSource": "Marketing",
    "LeadSourceCampaignName__c": "='>TO DO<'!$C$2",
    "Country_Code__c": "FR",
    "insee_activiteprincipaleunitelegale__c": "58.29B",
    "insee_codepostaletablissement__c": 78230,
    "isDuplicate": "=IF(INDIRECT(CONCATENATE(\"B\",Row())) <> \"\",(VLOOKUP(INDIRECT(CONCATENATE(\"B\",Row())),COMPARE_DEDUPLICATED!A:B,2,0)),\"\")",
    "full_name": "E Txx",
    "handle": "e-tx-xxx",
    "person_country": "",
    "City": "Le Pecq",
    "PostalCode": 78230,
    "AnnualRevenue": 12307523,
    "Founded_Year__c": 1984,
    "linkedin_company_id__c": "",
    "FirstName_encoded": "E",
    "LastName_encoded": "Txx",
    "Company_encoded": "4D",
    "personarank": "1 - Decision Maker"
  }
]

//For the **FALSE** branch, another example://

[
  {
    "Siret__c": xx,
    "NumberOfEmployees": 14,
    "Company": "AG",
    "FirstName": "A",
    "LastName": "M",
    "Phone": "+xxxx",
    "isMobile": "=IF(AND(iserror(FIND(\"+33 6\",INDIRECT(CONCATENATE(\"F\",ROW())))),iserror(FIND(\"+33 7\",INDIRECT(CONCATENATE(\"F\",ROW()))))),\"standard\",\"mobile\")",
    "Comments__c": "",
    "Industry": "CG",
    "Nombre_d_employ_s__c": "10 - 20",
    "linkedin_profile__c": "https://www.linkedin.com/in",
    "Title": "Ceo",
    "Website": "a.com",
    "Date_Sent_SDR__c": "2/26/2024",
    "RecordTypeId": "x",
    "LeadSource": "Marketing",
    "LeadSourceCampaignName__c": "='>TO DO<'!$C$2",
    "Country_Code__c": "FR",
    "insee_activiteprincipaleunitelegale__c": "x",
    "insee_codepostaletablissement__c": x,
    "isDuplicate": "=IF(INDIRECT(CONCATENATE(\"B\",Row())) <> \"\",(VLOOKUP(INDIRECT(CONCATENATE(\"B\",Row())),COMPARE_DEDUPLICATED!A:B,2,0)),\"\")",
    "full_name": "A M.",
    "handle": "am",
    "person_country": "",
    "City": "xx",
    "PostalCode": 3,
    "Founded_Year__c": 2006,
    "linkedin_company_id__c": "",
    "FirstName_encoded": "Arn",
    "LastName_encoded": "M",
    "Company_encoded": "AcGames",
    "personarank": "1 - Decision Maker"
  }
]```

That was for the first IF.

Now for the Zerobounce:

//GOOD ONE//
[
{
"address": 
"[email protected]",
"status": 
"catch-all",
"sub_status": 
"",
"free_email": 
false,
"did_you_mean": 
null,
"account": 
"e.t",
"domain": 
"4d.com",
"domain_age_days": 
"11066",
"smtp_provider": 
"",
"mx_found": 
"true",
"mx_record": 
"b4.adista.fr",
"firstname": 
"e",
"lastname": 
"t",
"gender": 
"male",
"country": 
null,
"region": 
null,
"city": 
null,
"zipcode": 
null,
"processed_at": 
"2024-02-26 09:24:11.385"
}
]```

//BAD ONE//
[

{

"address": "[email protected]",

"status": "valid",

"sub_status": "",

"free_email": false,

"did_you_mean": null,

"account": "valerie.marchal",

"domain": "s.com",

"domain_age_days": "9960",

"smtp_provider": "",

"mx_found": "true",

"mx_record": "mail.iap.s.com",

"firstname": "v",

"lastname": "m",

"gender": "female",

"country": null,

"region": null,

"city": null,

"zipcode": null,

"processed_at": "2024-02-26 09:26:59.064"

},

The examples didn’t match. But I suppose the issue could be with the output of the Zerobounce node, if an email is not valid then the Merge node won’t work.

Something like that could work

Thanks a lot! I will try that - Do you think that the loop over items node is necessary? Normally n8n tells me to avoid these kinds of nodes, but I’m eager to understand why you added it? Might it be more effective for a high number of records (I normally run this workflow with around 1K-2K records)?

The loop node acts differently than the usual iteration.

In regular workflow (without the Loop node) items will be processed in the next sequence: every item of the first node, then every item of the second node, and so on. All that processing counts as one execution

With the Loop node, the item processing is way more different. During the loop, every node processes only the N items (that are specified in the Loop node settings, but usually it is one item at a time). And every loop counts as a separate execution. That type of processing may help in complex workflows where you have a lot of IFs and checks that may or may not return items and thus may reduce the amount of issues

1 Like

Thanks a lot for your time barn4k :slight_smile:
Indeed my node was not giving the best output since it’s a pretty long & complicated one and with more than 1K results at a time it gives issues.
Have a nice rest of the week!

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