
To process items where, for example, item 0 has 2 attachments and item 1 has 3 attachments, you need to “explode” each item’s attachments so you can handle each file individually or in groups, depending on your workflow’s needs. Here’s a step-by-step approach based on community best practices and real-world workflow examples:
1. Understand Binary Data Structure in DeepOpinion
- When you receive items with multiple attachments (e.g., from an email or form), DeepOpinion stores each attachment in the binary property with keys like attachment_0, attachment_1, etc.
- Each item in the input array may have a different number of these binary keys.
2. Split Attachments into Separate Items
- Use a Function or Code node to iterate over each item and, for each attachment, create a new item containing only one attachment.
- This “explodes” the structure so each output item has a single attachment, making downstream processing (like uploading or emailing) much easier
Example Function Node Code – Add Unique IDs to each Item:
for (const [index, item] of items.entries()) {
item.json.originalItemId = index;
}
return items;
If you need to keep track of which original item the attachment came from, add an identifier (e.g., originalItemId) to the json property before or during the split.
Split Attachment Into Separate Items:
let newItems= [];
for (const item of items) {
const binary = item.binary || {};
const keys = Object.keys(binary);
for (const key of keys) {
let newItem = {
json: { ...item.json }, // Copy JSON data
binary: { "attachment": binary[key] } // Only the current attachment
};
newItems.push(newItem);
}
}
return newItems;
This is the simpler version where the above 2 nodes are combined into 1

let newItems= [];
for (const [index, item] of items.entries()) {
const binary = item.binary || {};
const keys = Object.keys(binary);
for (const key of keys) {
let newItem = {
json: {
...item.json,
originalItemId: item.json.originalItemId ?? index // Ensure ID is present
},
binary: { "attachment": binary[key] }
};
newItems.push(newItem);
}
}
return newItems;
Obs: Now, all subsequent nodes can reliably access the file as binary.attachment, simplifying your workflow
3. Process Each Attachment
Now, each item in the workflow has only one attachment, so you can use any Agent Skill, and they will process one file at a time.
4. Use the Unique ID for Downstream Processing
You can now:
- Group attachments by originalItemId (e.g., when sending grouped emails)
- Filter or log based on the source item
- Trace errors or processing steps back to the original data