Best Practice: Use Subflows for Batch Processing in Zenphi

When automating a process that handles a batch of items—like rows in a spreadsheet, form submissions, or email messages—it’s tempting to put all processing steps directly inside a For Each loop. While this works, there’s a more scalable and resilient way to do it in Zenphi: use a subflow.


Here’s why this approach is better:


Faster Processing Through Parallel Execution

Each subflow runs independently and in parallel. That means:

  • No waiting for item 1 to finish before item 2 starts

  • Significant reduction in total execution time.

  • Your batch is done in minutes, not hours.


Improved Error Isolation

When all processing is done inside the loop and one item fails, it can halt or impact the rest of the loop. But if you start a subflow in each iteration, each item is handled in a separate flow run.

  • If one fails, the others continue unaffected.

  • Easier to troubleshoot one failed run without stopping the whole batch.


Example Use Case

You need to send a personalized email and update a record for each row in a Google Sheet (200 rows). Instead of placing all steps inside the loop:

  1. Create a subflow that handles one item (email + update).

  2. In the main flow, loop through the rows and start the subflow for each.

Make sure that in the settings of the action Run Subflow you have switched the Run in Parallel on:

Final Thoughts

Using subflows in batch scenarios isn’t just a technical preference—it’s a best practice for reliability, scalability, and speed. It also aligns with modular design, making your automation easier to maintain and extend.

Give it a try in your next batch process—and let us know how it goes!