Iteration over multiple Arrays

I receive a Structure that contains multiple Arrays within Arrays:

The Request contains one Bundle with Data… The Data contains Conversations (in my case 19) and each Conversation multiple Messages.

I want to generate E-Mails where I combine all Messages from one Conversation.

I use an Repeater for the 19 Conversation and try to collect the Messages in an Iterator and combine the messages in a Text Aggregator. But somehow my brain create nonsense and the result is not working.

What I oversee, what is my error? I attach my blueprint.

Frank

blueprint.json (24.1 KB)

1. Put the top-level “conversations” array in an Iterator module.

2. Use the “join” built-in function to combine all the messages

Assuming module [2] is the Iterator module, e.g.:

{{ join(2.messages; newline + newline) }}

or if you want HTML format for emails:

{{ join(2.messages; "<br><br>") }}

For more information, see the function documentation in the Help Center.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

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

1 Like

Hi,

Many thanks. I tried, but it is not working. And from my understanding it cannot be working.

The structure is an array with a structure with an array:

I do an Iterator {{4.data.conversations}} to go over the Conversations.
A Join( {{4.data.conversations}} ) would not access the messages, only the Structure what contains messages, source etc). When I try a second Iterator and join over conversation[bundle position].messages, it did not work either - because again it is a structure with role, content, etc). The content is part of a structure, I think that is here the issue.

I tried some other ways based on the Help, I only get empty output or {object}

Frank

If you need further assistance, please provide the following:

Please provide the output bundles of the module [4] by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!

samliewrequest private consultation

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

1 Like

Sure,

here are the Input and Output Files.

input.txt (112.2 KB)

output.txt (103.2 KB)

Frank

Output

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 154,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{152.array}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -2066,
                            "y": -1390,
                            "name": "Iterate Convos"
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 155,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "{{join(map(154.messages; \"content\"); newline)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -1821,
                            "y": -1392,
                            "name": "Join Messages in Convo",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

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

1 Like