To group the paragraphs into batches of 20 and send the last batch with the remaining paragraphs, you can use a repeater and the slice function in Make. Here’s an overview of the process:
Add a repeater before the iterator and divide the total number of paragraphs by the number you want to group them by (20 in your case). This will give you the total number of times you need to process the batches of 20.
Use the slice function in the iterator to process the groups of 20 paragraphs. If the last batch has fewer than 20 paragraphs, the slice function will automatically stop at the end of the array, and it won’t fill it with empty elements.
Add a repeater before the iterator and divide the total number of paragraphs by your batch size (In my example my array had a length of 5 and I repeated by 2)
This can be tricky, Please do let me know if you think this makes sense, as there might be a better solution to this.
What you want to do After HTTP Module, Use an array aggregator that will grab all the data that you have. Based on your scenario though, the HTTP module is returning an array so we don’t need to use the array aggregator. So, Remove the iterator from there.
Add a Repeater after the HTTP module that will have a repeat parameter set to,
Initial Value: 1
Repeats: {{ceil(length(1.array) / 20)}}, whereby array is the data that is obtained from the HTTP response. So, for eg., if the total length is 64 then the iterator will run from 1 to 4.
After the Repeater is set, what you want to do now is split the array and then join the relevant data from the incoming array.
For testing, Put a Set a Variable Module that will have the following logic.
Slice array, {{slice(1.array; ((2.i - 1) * 20 + 1); 2.i * 20 + 1)}}. What this does is based on the iterator value, it will split the array into each element of 20.
After which you can manipulate the sliced/chunked array to pass it to Airtable or Chatpgpt. Either by performing a join or map function.
You can try this blueprint and see if it make sense : blueprint (31).json (6.6 KB)
I have done several tests and I don’t know where I am going wrong that it is not working properly.
The problem is that it “eats” the first paragraph. It does the whole process fine, but it starts grouping the paragraphs from the 2nd paragraph. I attach screenshots:
Change the initial value of your repeater to 0. You don’t need to use the ceil() function in the repeater (See my first post)
In the iterator, change you slice function parameters to the screenshot I shared you. I still recommend you to check out this article when it comes to the slice function parameters: Mastering the slice function in Make: Understanding zero-based and one-based indexing