How to use iterators in modules

Hi, everyone
I am new to make and I would like to ask for your help.

My workflow, in simplified form, is as follows: send the data received via webhook to the slack channel.

The example input data is a simple json structure as follows.

{
 "key1":"value1",
 "key2":"value2",
 "key3":"value3"
}

What I would like to do is send this key/value combination to slack, but not as json, but with some modifications. For example, I would like it to look like this.

The value of {{key1}} is {{value1}}
The value of {{key2}} is {{value2}}
The value of {{key3}} is {{value3}}

Using the iterator would mean that the message would be sent three times, but I want to send it as one message. Another problem is that the number of data elements is not known. I also don’t know what key is.

Anyway, I want to send the data I receive to slack in the form of a key/value combination.

How can this be achieved?

Hello @Natsuki_Nakajima,
You said that keys are not fixed and how many numbers of items are not fixed. That’s why this is tricky.
There are a couple of steps you need to follow.

  1. Wrap input into Array. Keep in mind that for iteration you always need Array as input. See more here. There are a couple of json and aggregation examples as well https://www.make.com/en/help/tools/flow-control#iterator-935250

  2. Set multiple variables to use in the next steps. We can use those functions directly on the next steps but just create separation to make it easier to understand.

  3. Use Iterator

  4. Use Text Aggregator to combine them all


    Output

  5. At last you can use the Slack module and use that output variable from the Text aggregation module.

Full Scenario Preview


Exported Blueprint : data_parsing_from_keys_using_iterator.json (7.3 KB)

2 Likes

An alternative solution assuming the format of the json being is fixed,
You can use Text Parser to convert keys and value in bundles and then use Text Aggregator.

Solution:

Text Parsing (using regex):
Regex value: “([^”]+)“:\s*”([^“]+)”

Text Aggregation:

Result:
Screenshot 2024-10-17 124757

1 Like

Thanks for your help!
I was finally able to complete my scenario :smiling_face_with_three_hearts:

Thank you for your help!
I thought your answer was very technical and could be used in the future!