• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

How to Format ChatGPT Text into an Array for the Iterator?

rodion6

Member
Consent to Access & Modify
I authorize Pabbly Support to log in to my account and make changes to the specified workflow for troubleshooting.
Hello everyone,

I'm working on a social media content automation on Pabbly Connect and I'm stuck on data formatting between two steps. I need your help.




My Workflow​

  • Workflow Name: "Sheets to YOUTUBE"
  • Step 10: OpenAI (ChatGPT) Module
  • Step 11: Iterator Module


The Problem​

The ChatGPT module gives me a response as a single text string. It's not in a valid JSON format, so the Iterator can't process it.

Here is an exact example of the text I'm receiving:

ESCENA 1 Visual: Un empresario tecnoexitoso, posando con un automóvil deportivo en una carretera rodeada de rascacielos ultra modernos.ESCENA 2 Visual: Una fábrica de tornillos en funcionamiento, maquinaria pesada en pleno uso.ESCENA 3 Visual: Una bodega grande y un tanto descuidada, sin ventanas, repleta de cajas y mercancías.ESCENA 4 Visual: Un fabricante de plástico en su línea de producción con montones de productos de plástico listos para embalaje.ESCENA 5 Visual: Dueños de negocios multimillonarios: uno está en un autobús lleno de gente, el otro está andando en bicicleta en una pista ciclista, el tercero está caminando en un barrio de clase media.ESCENA 6 Visual: Diferentes esquinas de diversas ciudades, con la sugerencia de que hay millonarios anónimos entre la gente común que camina a su alrededor.

My Goal​



I need to convert this text into a valid JSON array for the Iterator. This is what the final format should look like:

["ESCENA 1...", "ESCENA 2...", etc.]



What I've Tried​

I've tried adjusting the ChatGPT prompt and using the Text Formatter to replace newlines and other expressions, but I haven't been able to successfully extract just the array content.

Does anyone know of a reliable way to format this text to work with the Iterator? Which module or method would you recommend?

Any suggestions would be greatly appreciated. Thank you so much!
 

ArshilAhmad

Well-known member
Staff member
Please check out the video shared below; it may help you receive the response in a structured format. Make sure to disable 'Simple Response', then capture the data.


1758847080029.png


Thanks & Regards,
Arshil Ahmad
Customer Support Associate
🌐 Pabbly.com
👉Rate your support
 

rodion6

Member
Please check out the video shared below; it may help you receive the response in a structured format. Make sure to disable 'Simple Response', then capture the data.


View attachment 60862

Thanks & Regards,
Arshil Ahmad
Customer Support Associate
🌐 Pabbly.com
👉Rate your support
Thank you, Arshil, for the tutorial, but the interface has changed. I assume I now need to do this with 'Assistants,' but I don't see the 'Code' button (the step in the video at 7:50). Where can I find the JSON schema to copy and paste into Pabbly Connect?

1758849391885.png
 
Last edited:

rodion6

Member
Hello Pabbly Connect community! 👋

I'm setting up a workflow using the ChatGPT (Advanced) module to generate a visual script in JSON format, which I then need to process scene by scene using the Iterator module.

I previously received an outdated video guide for the OpenAI/ChatGPT setup, and after asking for help with no response, I tried to adapt the code myself.



1. ChatGPT (Advanced) Setup and Response​



I successfully configured ChatGPT to enforce a strict output structure using the response_format with json_schema.

The response from ChatGPT is a perfect JSON object containing an array named escenas:

JSON

Choices: [{"index":0,"message":{"role":"assistant","content":"{\"escenas\":[\"ESCENA 1 (0-4 seg) Visual: A clock alarm ringing in the morning, with a ray of sunshine entering through the window.\",\"ESCENA 2 (4-8 seg) Visual: A tech leader sitting at his desk, writing in a notebook with a smile.\",\"ESCENA 3 (8-12 seg) Visual: Graphs on a screen showing a 20% increase in productivity, with happy employees working.\",\"ESCENA 4 (12-16 seg) Visual: A CEO meditating on a factory rooftop as the sun rises, surrounded by tranquility.\",\"ESCENA 5 (16-20 seg) Visual: An image of a scale showing clear decisions and money, symbolizing the millions saved.\",\"ESCENA 6 (20-24 seg) Visual: A logistics entrepreneur reviewing a list of daily goals, with a relaxed and smiling team around him.\"]}","refusal":null,"annotations":[]},"logprobs":null,"finish_reason":"stop"}]




2. The Problem with the Iterator Module​



When I pass the response to the Iterator module, it fails to "drill down" into the JSON structure. Instead of iterating through the items in the escenas array, it treats the entire JSON object as a single item in an array:

Iterator Input (Process Arrays):

index 0: {"escenas":["ESCENA 1 (0-4 seg) Visual: A clock alarm ringing in the morning, with a ray of sunshine entering through the window.","ESCENA 2 (4-8 seg) Visual: A tech leader sitting at his desk, writing in a notebook with a smile.","ESCENA 3 (8-12 seg) Visual: Graphs on a screen showing a 20% increase in productivity, with happy employees working.","ESCENA 4 (12-16 seg) Visual: A CEO meditating on a factory rooftop as the sun rises, surrounded by tranquility.","ESCENA 5 (16-20 seg) Visual: An image of a scale showing clear decisions and money, symbolizing the millions saved.","ESCENA 6 (20-24 seg) Visual: A logistics entrepreneur reviewing a list of daily goals, with a relaxed and smiling team around him."]}

Because of this, I cannot map the individual scenes in the next action step of my workflow.




💡 My Question / Required Solution​



How can I properly configure the Iterator Module to access and iterate over the escenas array within the JSON output from ChatGPT?

I suspect I need to use the escenas key path when mapping the Array field in the Iterator, but I can't seem to get the syntax right in Pabbly Connect, or perhaps I need an intermediate step like the Data Transformer to extract the array first.

Any guidance on the exact mapping syntax or the best way to handle this JSON parsing/extraction would be greatly appreciated! Thank you for your help!
 

anushkasahu

Member
Staff member
Hello @rodion6,

Upon checking the workflow, we found that there were some extra characters being passed in the iterator which were not required, as it only executes the correct and proper array. We made some changes in the workflow by adding a regex to extract the array element, and everything is good to go now. You only need to check the mapping and map the newly generated response from the iterator after our modifications.

Please test it on your end and let us know if any further issues are encountered.
 

rodion6

Member
Thanks, Anushka! I can finally continue with my automation project. Pabbly is not only a powerful tool, but the support is genuinely superior to Zapier. I'm very happy with my decision, thank you!
 
Top