IF node continuing "true" branch on "false" condition

I’m fairly new to n8n and pretty certain I’m missing something fairly simple here. I have a workflow set up that takes an event_id from a webhook and then branches according to the value, using a series of chained IF nodes.

The issue I’m having is that even when the results of the first IF node are definitely FALSE, the workflow triggers the remaining steps in the TRUE branch (almost all HTTP Requests). I’ve tried doing this with the Switch node as well, without success.

Perhaps I’m misunderstanding how the branching logic works? Workflow JSON below:

The image below shows the IF node that is continuing the TRUE branch when the condition is false…

And the resulting nodes triggered after:

Thanks in advance for any help, I’m totally stumped on this one.

Hey @zinndesign! Welcome to the community!

This is just a hunch but I noticed that some of your HTTP nodes are set to always output data. Can you try again with this disables and see if you get better results?

Fantastic, thanks for the quick response… seems to have resolved the issue.

I had changed the workflow to “chain” the IF nodes, where before I had four separate nodes, one for each condition (e.g. event = x, event = y, etc.). But a webhook should be able to send data to multiple IF nodes at the same time, correct?

The SWITCH node would be ideal - but wasn’t working as expected for me, aways returned “false” for all variations, even when one was “true.”

(Thanks again for the initial solution and apologies for the immediate follow-up… still learning :upside_down_face:)

Hey @zinndesign! Glad that resolved the issue (I recently ran into something similar myself).

Yes, you can send the webhook to multiple IF nodes at the same time but be careful that this is only processing one set of data at a time. Otherwise, it is easy for the workflow to get confused.

As for the SEND node, I suspect that the always output data switch was causing you problems there as well.

Also, no apologies necessary! Trust me, everyone (even the n8n developers) on this forum is still learning!

3 Likes

Sorry, forgot to update here. The bug got fixed and got already released with the latest version.

Hi here,
I ran into the same issue but without any node with “always output data”. In fact I’m not using any http request.


Can U help plz ?
here is the whole workflow

Summary
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        260,
        310
      ]
    },
    {
      "parameters": {
        "command": "osascript -e \"tell application \\\"/Applications/Tunnelblick.app\\\"\" -e \"get state of first configuration where name = \\\"XX\\\"\" -e \"end tell\""
      },
      "name": "Get status of VPN X",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        480,
        310
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Get status of VPN X\"].json[\"stdout\"]}}",
              "value2": "CONNECTED"
            }
          ]
        }
      },
      "name": "IF CONNECTED",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        720,
        310
      ]
    },
    {
      "parameters": {
        "command": "osascript -e \"tell application \\\"/Applications/Tunnelblick.app\\\"\" -e \"connect \\\"XX\\\"\" -e \"end tell\""
      },
      "name": "Connect",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        920,
        410
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        1150,
        510
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"stdout\"]}}",
              "value2": "CONNECTED"
            }
          ]
        }
      },
      "name": "IF CONNECTED1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1660,
        350
      ]
    },
    {
      "parameters": {
        "channel": "coda-jerome",
        "text": "VPN Connecté",
        "as_user": true,
        "attachments": [],
        "otherOptions": {}
      },
      "name": "Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        1800,
        290
      ],
      "credentials": {
        "slackApi": "Jerome"
      }
    },
    {
      "parameters": {
        "functionCode": "const waitTimeSeconds = 1;\n\nreturn new Promise((resolve) => {\n  setTimeout(() => {\n    resolve(items);\n  }, waitTimeSeconds * 1000);\n});\n\n"
      },
      "name": "Wait1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1330,
        520
      ]
    },
    {
      "parameters": {
        "command": "osascript -e \"tell application \\\"/Applications/Tunnelblick.app\\\"\" -e \"get state of first configuration where name = \\\"XX\\\"\" -e \"end tell\""
      },
      "name": "Get status of VPN X1",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        1460,
        350
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get status of VPN X",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status of VPN X": {
      "main": [
        [
          {
            "node": "IF CONNECTED",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF CONNECTED": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Connect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Connect": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF CONNECTED1": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get status of VPN XX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status of VPN XX": {
      "main": [
        [
          {
            "node": "IF CONNECTED1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Sorry, do not understand. What issue do you have? The screenshot shows an IF-Node which does not have any output data for the “true” branch which looks correct as “AUTH” is not equal to “CONNECTED”. So the data would be in the “false” branch instead.

Also the workflow you did post seems to be incomplete. It contains the node “Get status of VPN X1” which is not connected to anything and also the node “IF CONNECTED1” which does also not have any input data.

Thanks Jan for you answer .
May be it is a misunderstanding how the if-node works.
With this screenshot I understand that this if-node, for “AUTH” Equal “CONNECTED” returns true… It should return false.
Now reading your answer, I may understand that I can look at the results of both answers “true” or “false”, and if one has data, then it is the branch that was fired ?

About the json, I had some confidential information inside, I changed some values, I may have corrupted something.
At the end, I solved my problem, but not by changing anything in if-node, but by removing the unuseful batchSize node. That should have had nothing to do with my problem, but it had !
I don’t understand why

Great to hear that it works now.

About the IF node. Yes, that is correct. Depending on the selection you can see what data each output will “send”.