How to Use Aggregate Node in n8n | Combine & Summarize Data

Learn how to use the n8n Aggregate node to combine and summarize data fields, creating consolidated notifications and reducing redundant messages.

Table of Contents

Overview

In this lesson, you will learn how to use the Aggregate node in n8n to combine multiple data entries into a single summarized item. This is especially useful for reducing redundant notifications, such as sending a single email with a list of pending orders instead of one email per order. By the end of this tutorial, you'll understand how to group data fields, summarize information, and optimize your workflow to reduce noise for your teams.


Understanding the Aggregate Node in n8n

The Aggregate node is designed to merge multiple items into one. It is particularly helpful when you want to:

  • Summarize multiple entries into a single message or data record.
  • Group data fields like email addresses or order IDs to avoid duplicates.
  • Send consolidated notifications to teams instead of multiple repetitive messages.

Why Use the Aggregate Node?

Imagine you have multiple orders from the same customer and you want to send only one email instead of multiple emails for each order. Or your operations team is receiving many Slack messages for each processing order, and you want to send just one summary message instead.

The Aggregate node lets you:

  • Combine multiple items into one.
  • Collect specific fields from all items into lists.
  • Create summarized messages for notifications.

You can also combine the Aggregate node with other nodes like the Remove Duplicates Node in n8n to ensure your aggregated lists do not contain repeated entries, improving the quality of your notifications.

For more details on how to structure your workflow logic, refer to the n8n flow logic documentation{:target="_blank"}.


Setting Up the Aggregate Node: Step-by-Step

1. Prepare Your Input Data

Before using the Aggregate node, ensure your data contains the fields you want to summarize. For example, your dataset might include:

  • orderID
  • orderStatus
  • orderPriority
  • fullName (a merged field of first and last name)

You might have already filtered or transformed this data using other nodes like Set, Switch, or Merge.

If you want to apply complex branching or conditional logic before aggregation, consider using the Master Conditional Logic in n8n lesson to handle IF/ELSE branching effectively.

2. Add the Aggregate Node

  • In your n8n workflow, click the plus (+) button to add a new node.
  • Search for and select the Aggregate node.
  • Connect the node to the previous node that outputs the list of items you want to summarize.

3. Configure the Aggregate Node

You will see two main options:

  • Aggregate All Items: Combine all incoming items into a single item.
  • Aggregate Individual Fields: Select specific fields from all items to aggregate.

For example, you want to aggregate all orderID values into a list.

Steps to Aggregate Specific Fields:

  1. Click Add Field.
  2. Select orderID as the field to aggregate.
  3. Optionally rename the output field to something like pendingOrderIDs.
  4. Save the configuration.

4. Test the Aggregate Node

  • Click on Execute Node to see the output.
  • The output will be a single item with a field containing a list of all orderIDs.
  • The data structure will look like this:
[
  {
    "json": {
      "pendingOrderIDs": [
        "OD00001",
        "OD00002",
        "OD00003",
        "... more order IDs ..."
      ]
    }
  }
]

This means you have successfully combined multiple order IDs into one list.

For more advanced aggregation options, you can consult the n8n Merge node documentation{:target="_blank"}, which complements the Aggregate node by allowing different types of data merging.


Using Aggregate Node Output in Notifications

1. Connect Aggregate Node to Email or Slack Node

  • Disconnect your previous connection to the email or Slack node that was sending multiple messages.
  • Connect the output of the Aggregate node to the email/Slack node.

2. Configure the Notification Node

In your email or Slack node, use expressions to include the aggregated data.

For example, in the email subject or body, you can use:

  • Subject:
Pending Orders from Today - {{$now.format('YYYY-MM-DD')}}
  • Body:
Please check the following pending orders and contact the customers:

{{$json.pendingOrderIDs.join(', ')}}

This way, the email will contain a list of all pending order IDs in a single message.

3. Execute and Verify

  • Run the workflow to send the notification.
  • You should receive only one email or Slack message with the consolidated list of orders instead of multiple messages.

Practical Example: Aggregate Pending Orders for Customer Service

Let's say you want to notify your customer service team about all pending orders in one email.

Workflow Setup Summary

  1. Input: Filter your orders to only include those with status pending.
  2. Aggregate: Combine all orderIDs from these pending orders into a single list.
  3. Email Node: Send one email with the list of pending order IDs.

Aggregate Node Configuration Example

{
  "parameters": {
    "fieldsToAggregate": [
      {
        "fieldName": "orderID",
        "outputFieldName": "pendingOrderIDs"
      }
    ]
  }
}

Email Node Body (using n8n expression)

Hello Team,

Please connect with the customers to get the pending details for the following orders:

{{$json.pendingOrderIDs.join('\n')}}

If your workflow becomes complex, consider modularizing it using Sub-workflows in n8n, which can help keep your automation organized and reusable.


Tips for Using Aggregate Node Effectively

  • Always check the data structure: n8n nodes expect the input as a list of items. The Aggregate node outputs a list with a single item containing aggregated fields.
  • Use expressions to format data: Use JavaScript expressions for formatting dates or joining lists.
  • Combine with Switch and Set nodes: Use Switch to filter data based on conditions and Set to prepare fields before aggregation.
  • Avoid duplicates: Use the Remove Duplicate node after aggregation if your list contains repeated entries.

Common Mistakes and Troubleshooting

Mistake 1: Sending Multiple Emails Instead of One

  • Cause: Connecting the email node directly to the node outputting multiple items.
  • Fix: Insert an Aggregate node to combine items first, then connect to the email node.

Mistake 2: Aggregating Without Specifying Fields

  • Cause: Not selecting fields to aggregate or misunderstanding all vs. individual field aggregation.
  • Fix: Explicitly add the fields you want to aggregate in the Aggregate node configuration.

Mistake 3: Incorrect Expression Syntax

  • Cause: Using expressions without proper syntax, causing errors or empty fields.
  • Fix: Use the expression editor in n8n and test expressions step-by-step.

Mistake 4: Duplicate Entries in Aggregated List

  • Cause: Original data contains duplicates.
  • Fix: Use the Remove Duplicate node after aggregation to clean the list.

Homework: Adding Complex Conditions

As shown in the video, you might want to notify your operations team only for orders that are both:

  • High priority, AND
  • In pending or processing status (exclude delivered, shipped, cancelled, refunded)

Try to implement this by combining multiple conditions in a Switch node or a Set node before aggregating.

For guidance on building complex branching logic, check out the Master Conditional Logic in n8n lesson.



Quick Reference: Aggregate Node Cheat Sheet

Step Action
Add Aggregate Node Search and add Aggregate node to your workflow
Connect Input Connect node output that provides multiple items
Configure Fields to Aggregate Select fields like orderID, rename output field
Execute Node Run node to verify aggregation
Connect to Notification Node Connect Aggregate node output to Email/Slack node
Use Expressions Use expressions to format and display aggregated data

By following this tutorial, you can effectively use the Aggregate node in n8n to combine and summarize your data, making your notifications and workflows more efficient and less noisy.

Frequently Asked Questions

In the Aggregate node, add a field to aggregate, select 'orderID', and configure it to combine all order IDs into a single list output.

Yes, you can configure the Aggregate node to group data by fields like customer name or status to create summarized grouped outputs.

By combining multiple items into one summarized message or list, the Aggregate node prevents sending repetitive notifications for each individual item.

Aggregating all items merges everything into a single item, while aggregating individual fields lets you specify which fields to combine into lists or summaries.

Execute the Aggregate node in n8n and review the output to ensure fields like order IDs are combined into a single list as expected.

Dheeraj Sharma

Dheeraj Sharma

AI Systems Builder
Creator of the n8n Zero to Hero course (42 lessons, 31+ hours). I help solopreneurs build AI systems that grow revenue without growing workload.

Get the n8n Mastery Bundle

All workflows, cheat sheets, and premium resources from the entire course in one package.

Get Premium Resources