The Array Aggregator: Learn How to Use This Tool in a Scenario

Mar 13, 2020 | 3 minutes
The Array Aggregator Learn How to Use This Tool in a Scenario

The array aggregator is a unique Make tool that can take your scenarios to a whole new level. If you wish for a detailed explanation before going into this tutorial, please read this other post covering iterators and array aggregators

What this scenario does: Retrieves files from a folder in Google Drive, aggregates the files and sends them as attachments in a single mail. 

Level Of Difficulty: Beginner

Implementation Time: Approximately 15 mins 

Assumptions: You have a Google account for Google Drive and Gmail. 

This tutorial focuses on one of Make’s most powerful inbuilt tools, the Array Aggregator. The function of this tool is to combine multiple bundles of data into a single array containing collections of specified items. 

The purpose of the Array Aggregator in this specific scenario is to combine multiple files in order to send them as attachments in 1 email. Without the Array Aggregator, the files are retrieved and emailed one by one resulting in multiple emails being sent.

Configuring the scenario

The scenario consists of the following modules:

  • Google Drive > Watch files in folder

  • Array Aggregator

  • Gmail > Send an email

Here’s the scenario:

Add the Google Drive > Watch files in the folder module and click on it to configure. Here, select the folder that you want to watch (folder that you upload the files to). You can leave the other fields as is: 

Scroll down to the Maximum number of downloaded files. This is the maximum number of downloaded files that will be retrieved in one cycle execution. 

Set this number to 5 so that the email will contain a maximum of 5 attachments: 

The Array Aggregator is found under tools located at the bottom of the scenario builder: 

After adding the Array Aggregator, you need to configure it. Under the Source module, the Google Drive > Watch files in folder module is automatically selected as it’s the only preceding module: 

Next is the Target Structure type. 

It’s important to note that if there is no module attached to the right of the Array Aggregator__, (the Gmail module in this case) you’ll only see the custom option available in this menu: 

Since the goal is to send an email, you need to add the Gmail > Send an email module after the Array Aggregator. Then, come back to the Array Aggregator to select the Target structure type and you’ll see additional options in this menu. 

Now select the Attachments option which essentially allows you to create an array as per the structure accepted by the Gmail module. 

Following that, select the Google Drive > Watch files in folder module as the Source File:

Next, configure the Gmail module that you just added. Add the recipient, subject line and content of the email: 

Then, toggle the map switch and simply map the Array[] element outputted by the Array Aggregator to the Attachments field: 

Now you need to right click on the Google Drive module, select where to start processing from and select All files:

Testing the scenario

Time to test the scenario. First click on the Save button at the bottom of the screen to save the scenario. 

Next, ensure that you have at least 5 files uploaded to the folder in Google Drive and then click on the Run once button to execute the scenario: 

Here you can see that the scenario execution is successful. You can click on the numbered circles to view the output of each module.

This number signifies the number of operations consumed by each module in a single execution: 

Click on the numbered circle above the Array Aggregator to view the output. Here you can see that 5 bundles pass through from the Google Drive module to the Array Aggregator as an input: 

The Array Aggregator then combines the 5 bundles in a single array containing collections of the files. 

In other words, the Array Aggregator outputs one bundle of data with multiple collections, each corresponding to a bundle generated by the module whose output you wish to aggregate - the Google Drive module in this case: 

The bundle passes through to the Gmail module as an input and the result is that the recipient receives 1 email with all 5 attachments as intended: 

Perfect! Now go back to the scenario and click on the Clock icon to set the schedule of the scenario executions. There are various options to choose from that are self-explanatory: 

Finally, set the scenario to on by clicking the switch at the bottom left corner: 

There you have it. Now you see the power of the Array Aggregator in a scenario. Hope you found this tutorial useful!

Happy Automating! 

  • 437 likes

Wayne

Wayne Govender

Solutions Architect at Make who loves all things tech with a focus on workflow automation. Also enjoys fitness and spending too much time on YouTube.

Like this use case? Spread the word.

Get monthly automation inspiration

Join 75,000+ Makers and get the freshest content delivered straight to your inbox.