How do I aggregate operations? (Please, I need help)

:bullseye: What is your goal?

I’ve created a scenario in which I’m using DeBank API to get the info about list of wallets, then I want to analyze this info with ChatGPT module.

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

In this scenario I’m using iterator, which as a result makes 14 operations with 1 bundle in each operation(each bundle holds the info i need).
I want to create a JSON which would aggregate all bundles from these 14 operations from the iterator.
For that I did Array Aggregator, but as a result it also makes 14 operation with 14 JSONs, and if I connect ChatGPT module after it, it just gives me 14 prompts, when I need one which would analyze all aggregated info.

To sum up: the problem is that after iterator I somehow need to have a module which would as a result have 1 operation with all previous operations (and bundles in it) from the iterator.
( Also, I put the last iterator as a source module in the Array Aggregator)

Or if there is other way to analyze info from those 14 operations in one prompt in ChatGPT - I’m open to try!

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey there,

you are aggregating the wrong module. Change the source module to the one producing the extra bundles.

1 Like

I’ve put The last iterator with 14 operations as a source model in Aggregator, but it still sends me 14 operations as a result and I need just one :sob:

Exactly. That iterator is processing 14 incoming bundles, not creating 14 new bundles. Change the source to whichever module is creating the extra bundles.

(P.S It’s my first day in make)

But whatever module I put as a source in aggregator it would still give me the same amount of operations as which were in the source module isn’t it?

The last iterator (number 22 on the screen) creates 14 operations with 1 bundle in each. These bundles hold all the info I need.

But if I use Aggregator with iterator 22 as a source i still get 14 operations as a result

Again, the last iterator did not create 14 bundles. It processed 14 existing bundles. There is nothing to aggregate there.

The iterator before only processed 3 incoming bundles, yet the one after it ran 14 times. Meaning the iterator before it is the one that creates the new bundles. So you need to put that one as the source module. Or even before that - the search module processes one incoming bundle and the iterator after it is processing 3. So that one also created new bundles and maybe this is the source module you want to go back to. Depending on what each module is producing as output.

My current problem is that Aggregator makes the same amount of operations as the source module in it and I need only one operation in Aggregator as a result.


Here is the result of Aggregator if I set iterator 6 as a source module - it still makes 3 operations as a result.

Basically aggregator does not aggregate lol

And if I put HTTP module as a source in aggregator it will still make 3 operations

So change the source module to the Search module at the beginning of the scenario. That’s the first module that ran only once and produced extra bundles.

2 Likes

I can’t believe it worked.

Thank you so much, god bless you!
I’ve spent the whole day trying to figure out how to fix it lol

1 Like

Also, it looks like iterator 20 and iterator 22 aren’t actually doing anything. The idea of an iterator is when you have an array of items, the iterator module would break it down and give you a separate bundle for each item in the array. Looking at the amount of bundles produced, only iterator 6 is doing that.

I use the second iterator to put a filter for the data

Welcome to the Make community!

Combining Bundles Using Aggregators

Every result/item from some module types (like Trigger / Iterator / List / Search / Match modules) can potentially and likely output more than one bundle. These multiple bundles will individually run subsequent modules once per bundle, which is not optimal in most cases:

  • one operation per bundle per module, which could lead to…
  • use of multiple credits per bundle per module (some modules use more than one credit)
View example screenshots

Aggregator Example

The “Search Rows” module runs one time, returning 999 results (999 bundles).

  • Without Aggregator: the tools module run 999 times (999 operations)


    (and if there are more modules, they run 999 times each)

  • With Aggregator: the tools module only runs 1 time (1 operation)

:warning: Warning: :police_car_light:
This can easily use your entire quota of credits if you are not careful or fail to understand this concept.

To “combine” multiple bundles into a single variable, so that you can process all of the items in a single operation, you’ll need to use an aggregator. Aggregators is a type of module that accumulates bundles and outputs one bundle (unless you are using “Group By”). An example of a commonly-used aggregator module is the Array aggregator module.

You can find out more about some other aggregator modules here:

Question: Which is the best aggregator do you think you’ll need for your use-case?

Mapping a Complex (Collection) Structure Into an Array Field

The Array Aggregator module is very powerful because it allows you to build a new complex array of collections that matches a later module’s array field to map multiple items (collections) to it. Such fields initially may allow you to manually add individual items, but toggle the “Map” switch on, and you can map an array variable (from an Array Aggregator) containing multiple collections.

Simply select the respective “Target structure type” in an Array Aggregator module.

As you can see from the above example, the “Map” toggle on complex fields are used when you have an array variable (like from an array aggregator).

:clipboard: Note: :light_bulb:
Other combinations of modules may also allow you to generate an array that matches a future module field’s array structure, like “Aggregate to JSON + Parse JSON”, or “Create JSON + Parse JSON”, but this is an advanced topic.

Question: Are you mapping your array into a field that accepts more than one item/collection?

Example

Here is an example of how your scenario could look like:

This is just an example. Your solution may or may not look like this depending on requirements and actual data.

For more information, see “Mapping with arrays” in the Help Centre. I also suggest going through the Make Academy, which also covers the use of Iterators & Aggregators.

@samliew