How to Implement Nested Two-Layer do-while Loops in Make?

I need to implement complex logic similar to nested do-while loops in programming.

Here are my specific requirements:

Outer Loop: Execute a certain operation N times or until a specific condition is met.
Inner Loop: Within each iteration of the outer loop, execute another set of operations M times or until another condition is met.
I found a similar topic on the forum mentioning the use of the repeater-error method to achieve something close to a do-while loop, but I’m not clear if this method can be applied to nested loops.
Below is a flowchart illustrating the logic I am trying to achieve:

Questions:

Has anyone successfully implemented similar nested loop functionality on the Make platform?
Could you please share detailed steps or configuration methods for implementing nested loops?
Any examples or guidance would be greatly appreciated!
I also came across some related content in the post “Google Drive - Search for Files/Folders,” but I’m still unsure if it can be applied to nested loops.

Thank you in advance for your help!

Hello,

welcome to the Make community!
Because of the way Make is designed, it will be difficult to do nested loops like this only with repeaters.
BUT, since loopings are done automatically when Make retrieves multiple records from an API call, you would normally be able to do what you describe here. We need to understand what data you are picking, and what you want to achieve.

As an example, if you retrieve 10 rows in a Google Spreadsheet, it will loop 10 times, and you can add a filter to “stop” looping when a condition is met. And also, in each loop, if you call another API that returns you 5 records, you will have an inner loop (5 times for each of the 10 outer loops) that you can also stop with a filter.

So can you tell us what you want to achieve so that we see if it’s doable out-of-the-box?

Benjamin

1 Like

Thank you for your quick response and detailed explanation!

I would like to describe my specific use case to better illustrate how I need to achieve nested loops on the Make platform.

In my use case, I am calling the OpenAI API, and the specific steps are as follows:

  1. Invoke Coordinator: Call the OpenAI API to break down the task into several subtasks.

  2. Invoke Sub-task: Call the OpenAI API to handle each sub-task and check if the sub-task is completed. If the sub-task’s output exceeds 4096 tokens (the maximum return limit of 4096 tokens), it needs to be handled through loop calls until the sub-task is completed.

  3. Return Result: After the sub-task is completed, record the results of each sub-task.

  4. Return to Invoke Coordinator: The Invoke Coordinator decides, based on the recorded results of each sub-task, whether to continue with the next sub-task or end the task.

Is it possible to implement these nested loops?

Additionally, if the OpenAI module can automatically handle cases where the output exceeds 4096 tokens and achieve a continue effect, then this issue could be easily resolved. Do you know if the current OpenAI module provided by Make supports this functionality?

Thank you very much for your help!

Hi Benjamin, thank you

Although it might not be strictly necessary to use two loops to solve the problem, it would be much easier if I could. Therefore, having a break functionality in the repeater module would be very helpful.

Of course, if the OpenAI module can automatically handle cases where the output exceeds 4096 tokens and achieve a continue effect, then this issue could be easily resolved. That would be even better.

Do you know if the current ChatGPT module provided by Make supports this functionality?

Thank you very much for your help!

Thanks for the details!!
I have to say that I’m a bit lost with the subtasks and other topics with OpenAI. What I know it that « Message an Assistant » module allows you to provide a threadID and continue a conversation, maybe it could help?

Anyway, Make unfortunately doesn’t provide any Break capabilities for the Repeater. It’s due to the fact that the Repeater is (only) a bundle generator that generates a « repeat » number of bundles. Once bundles are here, the only way not to execute the rest of the modules is to use filters and get/set variables.
So what you want to do can be achieved but you won’t like the logic you have to build :sweat_smile::sweat_smile::sweat_smile:

Another thing you should consider: in the OpenAI app of Make, and like most Apps, you have a module called « Make an API Call » which allows you to call any endpoint that doesn’t exist as a module. It allows you to « extend » the use of the API. So if you know an endpoint that could do what you need in one execution, you could have a look there.

Benjamin

Hi Benjamin

Thank you for your detailed response!

Due to time constraints, I haven’t had a chance to look into the “Message an Assistant” module yet. Instead, I have implemented the solution using filters and get/set variables, although it is somewhat cumbersome and redundant. I have tested it a few times, but since the results have not exceeded the 4096 token limit, I am still unsure if the continue processing logic will work properly.

Using the “Make an API Call” module also faces the same limitation, as this is the maximum return limit imposed by the OpenAI API.

For now, I will close this issue. I’ll get back to you if I run into any issues in the future that I can’t resolve.

Thank you again for your assistance!

joa

3 Likes