Splitting an object into lines for HTML template (Gmail)

Hi everyone,
A new n8n user here trying to understand the platform (no prior knowledge in alternatives / code)

I am trying to send the a JSON to ChatGPT to analyze and categorize a list of emails by 2 categories: Work / Personal, and have the output sent via gmail.

My problem:
When I am adding the object that includes the emails (workemails) // [personalemails]
The text is presented as a long string.
I researched multiple ways to split the string but it either didn’t work or was too complicated for me to understand based on the information at hand.

In the example screenshot you can see I have added an object to the email that includes 2 values:

  1. Welcome to Claude - Let’s get started
  2. Security Alert.
    image

Lastly, adding the ChatGPT prompt below:
Go through this email summary and identify the email category. personal or work. Name each email by {{ $json.data[1].Subject }}
Have at least 2 emails in Personal Emails.
Use this format to output
{
“workemails”: [
“work 1”,
“work 2”,
“work 3”
],
“peronsalemails”:
[
“personal 1”
“personal 2”
“personal 3”
]
}

Input Data:

{{ $json.data.toJsonString() }}

PS.
Idk if it matters, but I took a template that does something similar and adjusted it.
Thank you.

1 Like

Hi @Ben_Karni,

Can you copy your workflow and paste it into a code block? That will help determine the issue.

Best,

Robert

Hey,
Thank you so much for the reply.
I have actually managed to sort this out alone!
Needed to add a .map function :slight_smile:

1 Like

Glad you got it to work!