Aggregate data to a single email

Describe the problem/error/question

My webhook receives messages at irregular intervals. I aim to aggregate these messages and send out an email once I’ve accumulated 5 events. This email will include the ‘Description’ field from each of the last 5 events. After sending the email, the counter should reset, and a new email will be dispatched after the next set of 5 events is received.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

The email is not sent.

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @tall27_Tal, welcome to the community!

I am afraid this isn’t quite how n8n works. Each individual webhook would trigger a new workflow execution that is unaware of previous executions.

The Split In Batch node would be able to create smaller batches when multiple items are processed in a single workflow, but it would not be capable of retrieving data from previous executions.

So to achieve a message that is only sent after 5 incoming webhooks you’d need to include some form of data storage into your logic (a database for example). Now for each incoming webhook you’d do two things:

  1. Write the relevant data into your database
  2. Query your database and see if you have 5 or more results. If so, send your email, and delete the processed items from your database

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.