How to split modules inside same scenario

:bullseye: What is your goal?

I am building a scenario that fetches 10 competitor Instagram URLs every week, sends to ai and help create content in our own brand voice and in accordance with our content calendar.

:thinking: What is the problem & what have you tried?

The output is not as intended. I am stuck at a point where I want 10 iterations of modules to be completed first, stored in google sheets, then the top performing posts should be sent to AI. which filter I can add to make sure this happens? I am using make free tier, and I want everything inside same scenario.

:clipboard: Error messages or input/output bundles

I have a google sheet where all the scrapped data should go, after 10 complete iterations. Then only top performing posts should go to AI via text aggregator. what happens instead is that each iteration completes from beginning till the end, due to which scrapped data doesn’t go inside google sheet, so top perforners are not filtered, and I am getting wrong output.

What you are seeing is how Make executes by design. A scenario pushes one bundle at a time through the entire route, so bundle 1 reaches the AI module before bundle 2 has even been scraped. A filter cannot fix that, because a filter only decides whether a single bundle passes, it never waits for the other bundles.

The only module that waits for a complete cycle is an aggregator. Everything placed after an aggregator runs once, after the last bundle of that cycle has arrived. So the order you want is: the module that produces the 10 URLs, then the scraping module, then Google Sheets Add a Row, then an Array aggregator, then your selection step, then the AI module.

The Sheets write stays inside the loop, so all 10 rows are written one by one. The Array aggregator sits directly after it. Set its Source Module to the module that started the cycle, which is the iterator or whatever outputs the 10 items, and tick the fields you need later, for example the URL and the metric you rank by. After that aggregator you have exactly one bundle holding all 10 records.

For the top performers you have two options at that point.

One, do it in the mapping. On the aggregated array you can use sort and slice, for example slice(sort(array; desc; likes); 0; 3), and feed the result into your text aggregator or straight into the AI module.

Two, read the data back out of the sheet. Put a Google Sheets Search Rows module after the aggregator and let the sheet do the sorting and the row limit. That also gives you one clean list, and it makes it easier to compare across weeks later.

One thing to check before you rebuild. Run the scenario once and look at the output of the module that sits in front of the scraping step. If it returns 10 separate bundles, an aggregator is all you need. If it returns a single bundle with an array inside it, add an Iterator first, otherwise there is no cycle for the aggregator to close.

On the free tier this also keeps the operation count down, since aggregating before the AI module turns 10 AI calls into 1.