Major Bug in IF node

Hi, the IF node is separating incoming data into 2 streams correctly. However it is sending data of the 1st stream in the 2nd stream also. Giving an example below:
Here, I have created a workflow wherein contacts from hubspot are sent to IF node. And then from IF node, the ‘true’ stream goes into Set1 node and the ‘false’ stream goes into Set2 node.

In Set1, I have a formula which strips +91 from the phone number. After stripping +91 I get the following result:

In Set 2, there is no formula and the raw phone numbers are shown:

If you see, both nodes are getting the same ‘raw phone numbers’ from the IF node.

However, strangely, in the IF node, these 2 numbers are only in the ‘TRUE’ stream. The ‘FALSE’ stream has completely different phone numbers which are not even getting sent to the Set2 node.

This is causing major issues. kindly help

You may need to change your combine option on the IF node to ANY instead of ALL? Without an example to work with it’s difficult to help with this.

@djangelic

  • i tried by changing the combine option to ANY but it didnt solve the issue.
  • i am giving below the code of the workflow so that it helps in debugging it:
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -140,
        500
      ]
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "getRecentlyCreatedUpdated",
        "limit": 50,
        "filters": {}
      },
      "name": "Hubspot",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 1,
      "position": [
        280,
        160
      ],
      "credentials": {
        "hubspotApi": {
          "id": "98",
          "name": "Saandhy Hubspot account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "dateTime": [],
          "number": [
            {
              "value1": "={{$node[\"Hubspot\"].json[\"properties\"][\"createdate\"][\"value\"]}}",
              "operation": "larger",
              "value2": "={{$json[\"lasttenunix\"]}}"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1040,
        140
      ]
    },
    {
      "parameters": {
        "action": "calculate",
        "value": "={{$json[\"current time\"]}}",
        "operation": "subtract",
        "duration": 30,
        "timeUnit": "hours",
        "dataPropertyName": "lasttenmins",
        "options": {}
      },
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        700,
        100
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [],
          "number": [
            {
              "name": "current time",
              "value": "={{new Date().getTime()}}"
            }
          ]
        },
        "options": {
          "dotNotation": true
        }
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        500,
        180
      ]
    },
    {
      "parameters": {
        "value": "={{$json[\"lasttenmins\"]}}",
        "dataPropertyName": "lasttenunix",
        "toFormat": "x",
        "options": {}
      },
      "name": "Date & Time2",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        860,
        0
      ]
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "requestMethod": "POST",
        "url": "https://api.interakt.ai/v1/public/track/users/",
        "jsonParameters": true,
        "options": {
          "batchInterval": 2,
          "batchSize": 10
        },
        "bodyParametersJson": "={\n\"phoneNumber\": \"{{$json[\"phone\"]}}\",\n\"traits\": {\"name\": \"{{$node[\"Hubspot1\"].json[\"properties\"][\"firstname\"][\"value\"]}} {{$node[\"Hubspot1\"].json[\"properties\"][\"lastname\"][\"value\"]}}\",\"email\":\"{{$node[\"Hubspot1\"].json[\"properties\"][\"email\"][\"value\"]}}\"}}",
        "headerParametersJson": "="
      },
      "name": "HTTP Request5",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1400,
        660
      ],
      "credentials": {
        "httpBasicAuth": {
          "id": "72",
          "name": "Conversations.ai Interakt"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "get",
        "contactId": "={{$node[\"Hubspot\"].json[\"identity-profiles\"][0][\"vid\"]}}",
        "additionalFields": {}
      },
      "name": "Hubspot1",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 1,
      "position": [
        720,
        420
      ],
      "credentials": {
        "hubspotApi": {
          "id": "98",
          "name": "Saandhy Hubspot account"
        }
      }
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 3,
              "unit": "minutes"
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        60,
        180
      ]
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "requestMethod": "POST",
        "url": "https://api.interakt.ai/v1/public/track/events/",
        "jsonParameters": true,
        "options": {
          "batchInterval": 2,
          "batchSize": 10
        },
        "bodyParametersJson": "={\n\"phoneNumber\": \"{{$json[\"phone\"]}}\",\n\"event\": \"Lead Created\",\n\"traits\": {\"name\": \"{{$node[\"Hubspot1\"].json[\"properties\"][\"firstname\"][\"value\"]}} {{$node[\"Hubspot1\"].json[\"properties\"][\"lastname\"][\"value\"]}}\",\"email\":\"{{$node[\"Hubspot1\"].json[\"properties\"][\"email\"][\"value\"]}}\"}}",
        "headerParametersJson": "="
      },
      "name": "HTTP Request4",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1640,
        620
      ],
      "credentials": {
        "httpBasicAuth": {
          "id": "72",
          "name": "Conversations.ai Interakt"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "phone",
              "value": "={{$node[\"Hubspot1\"].json[\"properties\"][\"phone\"][\"value\"].startsWith(\"+91\") ? $node[\"Hubspot1\"].json[\"properties\"][\"phone\"][\"value\"].slice(3) : $json[\"phone\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1180,
        380
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Hubspot1\"].json[\"properties\"][\"phone\"][\"value\"]}}",
              "operation": "startsWith",
              "value2": "+91"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "IF2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        940,
        380
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "requestMethod": "POST",
        "url": "https://api.interakt.ai/v1/public/track/users/",
        "jsonParameters": true,
        "options": {
          "batchInterval": 2,
          "batchSize": 10
        },
        "bodyParametersJson": "={\n\"phoneNumber\": \"{{$json[\"phone\"]}}\",\n\"traits\": {\"name\": \"{{$node[\"Hubspot1\"].json[\"properties\"][\"firstname\"][\"value\"]}} {{$node[\"Hubspot1\"].json[\"properties\"][\"lastname\"][\"value\"]}}\", \"email\":\"{{$node[\"Hubspot1\"].json[\"properties\"][\"email\"][\"value\"]}}\"}}",
        "headerParametersJson": "="
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1540,
        400
      ],
      "credentials": {
        "httpBasicAuth": {
          "id": "72",
          "name": "Conversations.ai Interakt"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "requestMethod": "POST",
        "url": "https://api.interakt.ai/v1/public/track/events/",
        "jsonParameters": true,
        "options": {
          "batchInterval": 2,
          "batchSize": 10
        },
        "bodyParametersJson": "={\n\"phoneNumber\": \"{{$node[\"Set1\"].json[\"phone\"]}}\",\n\"event\": \"Lead Created\",\n\"traits\": {\"name\": \"{{$node[\"Hubspot1\"].json[\"properties\"][\"firstname\"][\"value\"]}} {{$node[\"Hubspot1\"].json[\"properties\"][\"lastname\"][\"value\"]}}\",\"email\":\"{{$node[\"Hubspot1\"].json[\"properties\"][\"email\"][\"value\"]}}\"}}",
        "headerParametersJson": "="
      },
      "name": "HTTP Request6",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1780,
        380
      ],
      "credentials": {
        "httpBasicAuth": {
          "id": "72",
          "name": "Conversations.ai Interakt"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "phone",
              "value": "={{$node[\"Hubspot1\"].json[\"properties\"][\"phone\"][\"value\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1160,
        600
      ],
      "continueOnFail": true
    }
  ],
  "connections": {
    "Hubspot": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Hubspot1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Date & Time2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time2": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request5": {
      "main": [
        [
          {
            "node": "HTTP Request4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hubspot1": {
      "main": [
        [
          {
            "node": "IF2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Hubspot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF2": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set2": {
      "main": [
        [
          {
            "node": "HTTP Request5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}```

@djangelic
also give a screenshare video describing the problem in details: Loom | Free Screen & Video Recording Software

Hey @Saandhy_Ganeriwala1,

I have just taken a look at your workflow and it looks like your Set nodes are not using the outputs from the If node and are instead using the output from the Hubspot node.

In Set1 change

{{$node["Hubspot1"].json["properties"]["phone"]["value"].startsWith("+91") ? $node["Hubspot1"].json["properties"]["phone"]["value"].slice(3) : $json["phone"]}}

To

{{$json["phone"].startsWith("+91") ? $json["phone"].slice(3) : $json["phone"]}}

Then in Set2 change:

{{$node["Hubspot1"].json["properties"]["phone"]["value"]}}

to

$json["phone"]

That should get that part working for you, I have not checked the API calls but if they are the same you could also just drop the If node and both set nodes then just use your Ternary operator when sending the data and it will sort it out for you.

1 Like