Combine data from multiple Router branches into one Gmail

:bullseye: What is your goal?

I have a scenario that processes shipment data using JSON → Iterator → Router.

I need to send one Gmail email containing:

Total number of shipments
Total shipment cost
Average shipment cost
A list of all Delayed shipments
A list of all In Transit shipments

The problem is that the Delayed and In Transit shipments are processed through separate Router branches, using filters and aggregators/text aggregators.

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

I understand that Router branches are independent, but I don’t understand how to make the output from both branches available to a single Gmail module.

I have also tried using Set Multiple Variables, but I’m unsure how the variables created in one Router branch can be reliably accessed by the Gmail module in another branch.

What is the recommended Make.com architecture for producing these two filtered lists and then combining them with the overall shipment summary into one Gmail email?

Hey there,

you use Get Multiple Variables on the last route to retrieve variables set on the upper routes.

The Router is what is making this hard, and you can remove it entirely. Routes do not converge in Make, so anything built across branches has to be stitched back together afterwards. If instead you put a single Array Aggregator straight after the Iterator, you get every shipment in one bundle, and one Gmail module can produce all five values from it.

With the aggregator as module 5, the summary parts are: total shipments {{length(5.array)}}, total cost {{sum(map(5.array; “cost”))}}, average {{avg(map(5.array; “cost”))}}.

For the two lists, map() takes a four-argument form that filters, which is the part that usually goes unnoticed. {{join(map(5.array; “shipment_id”; “status”; “Delayed”); ", ")}} returns only the delayed ones, and the same with “In Transit” gives the other list. Swap shipment_id for whichever field you want shown. No filters and no second aggregator needed.

Worth knowing why the Get Multiple Variables route would bite you later even though it does work today. If a run contains no Delayed shipments, that branch’s filter blocks, the variable is never set, and the final route reads an empty value rather than an empty list. The quiet day is when you would notice, which is the worst time to find out.

Its pretty simple- you must save your data as variables and retreive them on your last route. This approach sometimes is called as Make Magic Formula.

Its pretty well explained here: https://www.youtube.com/watch?v=4Q-5BsCtJu4