How can I loop over an array using the Iterator?

Hello

=>>This is what I would like to achieve: Loop over a list of handles to analyse each handle.

==>The list of handles is returned from a ChatCompletion Module in JSON. I told ChatGPT module to return this (and checked “parse JSON” in the settings:

{
“handles”: [
@handle1”,
@handle2
]
}

==>This is the output bundle of the ChatCompletion Module:
{
“result”: {
“handles”: [
@drsanjayparashar”,
@plasticsurgeryoffer
]
},

==>Now to loop over the array I chose the Iterator module. This is the input bundle:
[
{
“array”: [
{
“value”: “@drsanjayparashar
},
{
“value”: “@plasticsurgeryoffer
}
]
}
]

Input is the array:

It returns something that looks like it’s working.

==> Output bundle of the iterator module

[
{
“value”: “@drsanjayparashar”,
IMTINDEX”: 1,
IMTLENGTH”: 2
},
{
“value”: “@plasticsurgeryoffer”,
IMTINDEX”: 2,
IMTLENGTH”: 2
}
]

==> The “value” however is not accessible from the next module:

I know this question has been asked before, but I am unable to solve this on my own.
Thank you for helping.

Hi @Barbara2
You can paste {{16.value}} in next module.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like

Ok I solved this changing the JSON that I get from ChatGPT.

Before:
{
“handles”: [
@handle1”,
@handle2
]
}

After:

{
“handles”: [
“value”: @handle1",
“value”: “@handle2”,
“value”: “@handle3
]
}

==>This is the output bundle of the ChatCompletion Module:

Before:
{
“result”: {
“handles”: [
@drsanjayparashar”,
@plasticsurgeryoffer
]
},

After:
“result”: {
“handles”: [
{
“value”: “@drsanjayparashar
},
{
“value”: “@plasticsurgeryoffer
}
]
},

etc.

Now it’s accessible.

1 Like

Thanks haven’t tried this, but will next time.

1 Like

Hi @Barbara2
Glad to know you could solve the issue.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like