How to loop over an array and output fields

How do i output items from an array in a Slack message.
I have a Shopify integration using the “New Event” module where i listen for created orders.
As soon as an order comes in, i want to send a message to a Slack channel with the order details such as order number, items in order and total.

The issue I’m facing is that i don’t know how to iterate over the items in the “line_items” array.

Expected output:
Items:
Product A * 1 (Quantity)
Product B * 2

Screenshot:

Welcome to the Make community!

You’ll need an Iterator module to iterate the array of line items, then another aggregator to combine them into text.

Every result (item/record) from an iterator module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and has applies to many use-cases.

There are other types of aggregator modules, click the below links to find out more:

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

You cannot “loop” with inline functions in a field. It has to be done before it, with an Iterator + Aggregator combo.

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

1 Like

Hi @samliew !

Thanks for the quick response.

However this leaves me with an array just like the data i just got from Shopify.
How do i loop over the array in the text field of the Slack message:

Slack output:

Again i would like this output in the slack message:

Items:
Product A * 1 (Quantity)
Product B * 2

You cannot “loop” with inline functions in a field. It has to be done before it, with a separate Iterator + Aggregator combo.

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

1 Like

Can you please share an example of how to achieve this in the scenario? I’m totally lost in this logic :smiley:

I think you were already close, instead of an Array Aggregator, simply use a Text Aggregator.

Here’s an example

Screenshot_2024-06-05_140655

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

2 Likes

Hi @David_Rohof

Before slack module, please use an iterator and map “line_items” array inside the iterator. Then use “text aggregator” and use your formula like “item*quantity” inside text aggregator. then map the output from text aggregator in slack module.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support | Book Live Implementation
Visit us here
Youtube Channel

1 Like