Condition Node

Hi Team,

I’m trying to add condition to check if Imap Email trigger returned an email with attachment.
I want to check first if that email contains attachment to call e proper analyzer for example file info.
If there is not attachment it returns error in cortex.


The problem is to get the value of of attachment_0 and put it in the condition.


if there is any tricky ou best way to perfom this validation i will be glad if you share.
Thanks in advance.

You can use the expression {{ Object.keys($binary).length }}. It will return how many binary properties the previous node did output.

So an IF-Node that would return data on the True-Output if there is binary data would look like this:

  "nodes": [
      "parameters": {
        "conditions": {
          "number": [
              "value1": "={{Object.keys($binary).length}}",
              "operation": "larger"
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
  "connections": {}

Thank you @jan
Much appreciated

The binary variable Object.keys($binary) we can consider as the same with the Binary in the output data ? I can consider this approach for all conditions. Is it correct?

Not sure if I understand you correctly. But yes $binary is the binary data that you get as output of the previous node. To be exact it is the binary data of a specific item.

Hi @jan.
It’s me again.
Still in this case. One question regarding loops.
If i have more than one attachment how can i deal with it, iterate in this case,
And for example, create many observables using Thehive node based on each file.
Now i’m only able to get the attachment_0.
Best regards