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.
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:
Write the relevant data into your database
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