How to extract user + AI messages from parsed JSON (nested payload) to send via email?

Hey there!

I’ve been scratching my head over this for a while now.

I’m using an HTTP GET module to retrieve a conversation transcript that includes both human (user) messages and AI replies. The data comes in as a series of bundles, and each bundle has a payload field, which is a nested collection.

Some bundles include actual messages (either from the user or the AI), while others include internal prompts, debug data, or other metadata that I don’t need.

The HTTP module is set to parse JSON, but I’m stuck figuring out how to extract just the user’s queries and the AI’s replies from the nested structure and format them properly to send using a Send Email module.

For example, I’d like the final result to look like:

User: hey  
AI: Hello! How can I help you today?  
User: I need pricing info  
AI: Sure, would you like delivery or pickup?

Has anyone dealt with a similar case where you need to extract nested message data from a collection and map it cleanly for downstream modules?

Would appreciate any insight on how to access and pair these cleanly within Make.

Thanks!

Welcome to the Make community!

From your screenshot/output bundle, it appears that you have an ARRAY of items. What do you do when you have an array?

“Looping” Through Array Items

When you SEE an array in your module’s output, think of using an Iterator module.

In this example, responses is an array of items (collections). You’ll want to map this array in an Iterator module.

Question: Have you tried mapping your array variable into an Iterator module, ran the scenario, and view the output?

Next,

Combining Bundles Using Aggregators

Every result (item/record) from trigger/iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, 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 can apply to many use-cases like building of JSON, CSV, HTML.

You can find out more about the other types of aggregator modules here:

Question: Which type of aggregator do you think you’ll need?

Mapping a Specific Structure Into a Complex Field

The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

This is done using the “Target structure type” field in an Array Aggregator module.

Here is an example:

As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.

Question: Are you mapping your array into a field that accepts more than one “item”?

Example

Here is an example of how your scenario could look:

This is just an example. Your final solution may or may not look like this depending on your requirements and actual input data.

For more information, see the “Mapping with arrays” link below. You should also do the Make Academy, which also covers the use of Iterators & Aggregators.

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.