Working with loops: combine multiple iterations into one action, then expand again

Hi,

I have a workflow where I loop through multiple items.
For each item, I perform several actions (for example: extract some details, build a file, etc.).

At the end, I want to:

  • Send only one email per client (even if that client had multiple items).

  • After the email is sent, log all the individual items that were processed for that client, and include the email’s ID/reference in each logged record.

So effectively, one email should cover multiple iterations, but the logging step still needs to happen on a per-item basis, enriched with the email ID.

What would be the best way to structure this in n8n?
Is there a recommended pattern for:

  • doing multiple actions in a loop,

  • sending one notification per client,

  • and then writing back all the iteration details with the email reference?

Thanks!

Hey, can you share your workflow?

In n8n, you can structure your workflow like this:

  1. Group items by client using the Item Lists → Aggregate Items node.

  2. For each client group:

    • Build the file and send one email.

    • Capture or generate an email reference ID.

  3. Split the grouped items back out.

  4. Add the email ID to each item using a Set node.

  5. Log each item individually (e.g. to a database or API).

This way, you send one email per client but still log each item with the email reference.