How to Implement a Conditional "While Loop" in n8n Workflow (Without LLM/AI Agent node)?

Hi all,

I’m currently working on a workflow where I need to implement something like a conditional loop, similar to a while loop in traditional programming.

Use Case:

I have a list of entities, and for each entity, I need to make an HTTP call repeatedly until a favorable response is returned (e.g., a status or flag in the response indicates success). Once a favorable result is received, the loop should break out of the loop, and the workflow should move to the next node.

Question:

I’m aware that this kind of pattern can be implemented using AI Agents orchestrated through LLMs, but I’m curious—
Is there a way to do this using standard n8n nodes/triggers, without relying on an AI Agent Node?

Has anyone implemented a loop with conditional exit like this using native logic in n8n (e.g., Function, IF, Set, or Wait nodes)?
Any examples or pointers would be very helpful.

Thanks in advance for your insights!

1 Like

You can use ‘loop over item’ node.

1 Like

Something like this template.

Change the set field to your http request

The solution is you can always connect to previous node to make a loop.
But very very be careful on trigger infinite loop.

I guess you want to check like a job status is already done or not. set a wait after the if will be better on this scenario.

1 Like

In my case, i am having 6 entities from the previous HTTP node. For these 6 entities i want to invoke the next HTTP Node, which is essentially my in-house outlier detection API. I want to invoke the Outlier Detection HTTP node for these 6 entities one by one until one of them gets a “Not Outlier” status.

Hope this makes things clearer. Do share any insights regarding implementing the same.

In the meantime, I’ll try your solution and update here…