How can I group an array into chunks of 5 to send in batches?

Hi everyone! :waving_hand:

I’m working on a scenario where I need to process a list of LinkedIn leads (from a PhantomBuster JSON) and send them in batches of 5 leads at a time to OpenAI for qualification.

Here’s what I tried so far:

  • Using **Iterator + Array Aggregatorwith floor(divide(mapIndex; 5)) in the “Group by” field → :white_check_mark: iterates fine, :cross_mark: doesn’t actually group items into arrays as expected.
  • Tried Target structure type: Array or Array of collections, but that option doesn’t exist in my current modules.
  • Text Aggregator is also not available in my tools list.

What I really need is a true grouping of the original array into sub-arrays of 5 objects each.

Question:
:right_arrow: Is there a way to do this with a native Make function or some kind of JSON manipulation tool?

Goal:
To send smaller, controlled groups of leads to OpenAI for cost-effective, batch-based qualification — and avoid sending huge arrays or overloading the model.

Thanks in advance for any insight! :folded_hands:

1 Like

Hi @opstracquisition

Welcome to the community.

To Have a batch of leads in group of 5 you can follow these steps.

Step 1 : Use Repeater module to get no of repeats needed for no of groups of leads in set of 5 from your array of leads. you can use this formula in the repeater module: {{ceil(length(6.array) / 5)}}

Step 2 : Use iterator to slice the array of leads to get each batch of 5 using slice function, Use this formula: {{slice(6.array; 3.i; 3.i + 5)}} inside iterator.

This solution helps you to get equal parts of array or output bundles in set of any number. Later after that iteration of array into desired batches you can aggregate it further with text aggregator or array aggregator.

Pro Tip : Don’t go to mapping panel to search formula or function, simple type “/” and name of formula you want to search for, like “/slice” and you will get that easily to map in any input space.

I hope this helps!

Best
Prem Patel
Silver Partner x Level 5 Expert

Welcome to the Make community!

For more information, do view these similar questions previously asked by other community members, which may answer your question:

Next time, please try to search this forum first for existing answers. This may help you get to the solution faster, and also help keep the forum organised. Thanks for your cooperation!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.