Nested Loop help

Below is an image of part of my workflow. I have a report that I am pulling the list of services for which there are support tickets opened. This works great. I am then entering into this part of the flow that is intended to go to our ticketing system via an HTTP request node to pull the ticket info and ticket feed. I then use some code to clean up the output so it is more readable. As I do this, it flows into the combine node that continually appends the item so I can put all the ticket information (and feed) into a single file eventually.

My goal is to use this file to put it into an LLM to find patterns and help us pinpoint areas to improve. The problem comes in where one of the services has so many tickets that it is causing a memory error after this loop runs so many times. I would like to limit this loop to do 100 tickets at a time before emailing me the information and picking up with the next ticket. This should break down the ‘combined’ file into a small enough size to not cause the memory issue. I am having problems figuring out how to loop this back into the larger loop.

Let’s say we had 250 tickets for service A. I want it to send me 3 emails for Service A (100 for the first 2 and 50 in the last attachment). Then, I need to kick it out to the larger loop to move to the next service. I think I can figure out how to batch things, but not how to batch things and get back out to the larger loop. I can’t put my actual workflow in here since it contains keys.

I am open to any ideas on how to do this or a better way to accomplish this.

TIA!

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hey @Jamie_C , I would advise to avoid nested loops as you are likely to encounter unexpected result. Simply put, nested loops are not supported.

If you are to reuse the same Loop node with a different set of data, you need to reset it first. See Loop Node Only Processes the First Item - How to Fix? - #12 by Jon for more details.

hello @Jamie_C

Instead of using a loop node, use a sub-workflow. You may have as many sub-workflows as you can imagine. Plus once the execution in the sub-workflow is done, the memory from it gets released

1 Like

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