I’m new to using the N8N. I use some features of the SIEM QRadar API, to speed up some searches via API and search results for a pipeline under construction, using CHATGPT.
My question is:
In the API, at a certain point in the execution, it returns whether it is waiting, successfully executed or error.
How do I make a loop using the if function?
for example, if the status is wait, it checks again. If the result is success, it moves on to the next node
I have created an example using a random data API.
In the Switch Node, it checks whether the user’s nationality is DE (indicating success) or DK (indicating an error). In all other cases, the status is “waiting.”
When the status is “waiting,” it goes back to the HTTP node, with a Wait node in between to avoid overloading the API unnecessarily.
I’m also kinda new to n8n, but I had a similar challenge recently while working with an image generation API.
Here’s how I solved it using a simple IF loop setup with a delay:
Use case:
I read prompts from a Google Sheet, send them to an image generation API (PiAPI), wait for the result, check the status, and then download the image if it’s ready.
Workflow summary:
Trigger: Manual run (for testing)
Read data from Google Sheets
Send prompt to PiAPI (POST)
Wait node (just a few seconds)
GET status from PiAPI
IF node:
If status is complete → Go to “Get Image” → Save image to disk
If status is still waiting → Loop back to Wait and retry
This is what the flow looks like visually:
Hope this gives you an idea of how to implement a loop with IF + WAIT. It’s simple but effective for polling an API until it’s ready