# Condition Node

**URL:** <https://community.n8n.io/t/condition-node/5252>\
**Category:** Questions\
**Created:** [April 14, 2021, 10:15am UTC](https://community.n8n.io/t/condition-node/5252 "2021-04-14T10:15:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermanmaleiane](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hermanmaleiane/32/3884_2.png) [@hermanmaleiane](https://community.n8n.io/u/hermanmaleiane)\
**Post date:** [April 14, 2021, 10:15am UTC](https://community.n8n.io/t/condition-node/5252/1 "2021-04-14T10:15:27Z")

</div>

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.

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/3/3a103101cbd737d23707fc033de330e6f6a234a3.png).

The problem is to get the value of of **attachment\_0** and put it in the condition.

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/1/1044d231c1eb698c2e8350429b90b70ebcd687c1.png).

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/0/03117b21a304d9d5a818ba2fbc1cb632ea5e591b.png)

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

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [April 14, 2021, 10:49pm UTC](https://community.n8n.io/t/condition-node/5252/2 "2021-04-14T22:49:03Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![hermanmaleiane](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hermanmaleiane/32/3884_2.png) [@hermanmaleiane](https://community.n8n.io/u/hermanmaleiane)\
**Post date:** [April 15, 2021, 1:33pm UTC](https://community.n8n.io/t/condition-node/5252/3 "2021-04-15T13:33:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [April 15, 2021, 4:43pm UTC](https://community.n8n.io/t/condition-node/5252/4 "2021-04-15T16:43:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hermanmaleiane](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hermanmaleiane/32/3884_2.png) [@hermanmaleiane](https://community.n8n.io/u/hermanmaleiane)\
**Post date:** [April 20, 2021, 5:05am UTC](https://community.n8n.io/t/condition-node/5252/5 "2021-04-20T05:05:59Z")

</div>

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
