How to prepare a multidimensional array for ChatGPT

Dear Make-Team/Community,

our real problem is a little bit more complicated than the following scenario.
But the scenario describes our problem.

Here is the input:
It’s a simple JSON representing a more complex workflow with Gmail, Google Drive and Google Docs.

We are fetching mails from Gmail and are using an iterator to handle the attachments. To get the content of the attachments we are using Google Docs.

After iteration we have the subject from the Gmail module (here presented as MySubject) and the content of the two attachments.

Now we want to use the data for a ChatGPT-Prompt. It is very important for us to have beside the attachment contents the mailSubject and mailContent only one time in the prompt.

We try to use a text aggregator. But the text aggregator duplicates the subject and content as often as we have atttachments.

Have a loot at the following screenshot:

Is there a better way to merge outputs from an iterator or aggregater. I’ve already tried different solutions.

Here is the download of the blueprint.
Simple-Aggregation-Problem-Blueprint.json (4.6 KB)

Thank you in advance
Frank

Hi @Frank_Unkelbach , What is the ideal format of the message ?

subject1/mailContent1/attach1/content1/attach2/content2 ?

In Text aggregator you could use if() function :
if(bundleposition=1;subject1/mailcontent1/;emptystring)attach#/content#if(bundleposition<>bundletotal;/;emptystring)

This way you’re only adding subject/mailcontent only once (at bundleposition of the attachment iterator being 1)

1 Like

Great. That works perfect for us.
Thank you. :smiley:

1 Like