ChatGPT Module Returning Long String Instead of JSON Collection

Captura de pantalla 2025-05-08 a las 12.08.55|690x241

Hello community,

I’m trying to create a flow in Make that uses ChatGPT to process data about clients with overdue balances, grouped by salesperson. However, I’m encountering a persistent problem: even though I’ve configured the ChatGPT module to return the output as a JSON Object with JSON parsing enabled, Make keeps interpreting the result as a Long String instead of a Collection. This prevents me from accessing the data as mappable objects in subsequent modules.


Flow Description:

  1. Data Input:

    • The input data comes from a Google Sheets file containing information about clients, salespeople, due dates, overdue balances, and days past due.
    • The file is processed in Make to group clients by salesperson before sending the request to ChatGPT.
  2. ChatGPT Module (OpenAI):

    You are an expert assistant in credit management and collections. I will provide you with accumulated data about clients, including their overdue balances, days past due, associated salesperson, and the salesperson's email address. Your task is as follows:
    
    - Verify overdue payments: Identify clients with outstanding balances.
    - Group by salesperson: If there are multiple clients associated with the same salesperson or email address, group all those clients together under a single block for that salesperson.
    
    - Generate JSON: Return a single JSON object containing:
     - The name of the salesperson.
     - The email address of the salesperson.
     - The associated clients, with the following data for each client:
       - The name of the client.
       - The internal client number.
       - The due date.
       - The overdue balance.
       - The days past due.
    
    - Create email body: Additionally, create a generic email body in Markdown format for each salesperson with a summary of the clients with overdue balances.
    
    **Email Format:**
    - Start with a generic greeting using the value provided in the JSON under the "salesperson" key.
    - Include a list of clients with overdue balances, specifying the client name, overdue balance, due date, and days past due for each.
    - End with a generic closing and a wish for a good week.
    
    - Create internal summary: Generate a final internal summary in plain text for the credit department. This summary should include:
     - The names of the salespeople.
     - The clients with outstanding balances.
     - The amounts overdue for each client.
     - The number of days past due for each client.
     - The text should be simple and clear, without tables or Markdown.
    
    - Final Format: Generate the response grouped in a main JSON object where each salesperson has their list of clients with overdue balances, followed by the corresponding email body.
    
    

  • Assistant Role Message:

REQUIRED OUTPUT:
{
“avisos”: [
{
“comercial”: “Francisco Ruiz Gutierrez”,
“email”: “franciscoruiz@iberti.es”,
“clientes”: [
{
“nombre”: “MOTUM AUTOMOCION SL”,
“numero_interno”: “C020731”,
“fecha_vencimiento”: “19/04/2025”,
“saldo_vencido”: 163.35,
“dias_vencido”: 17
},
{
“nombre”: “GRUYSERV ELEVACION, S.L.”,
“numero_interno”: “C014624”,
“fecha_vencimiento”: “01/03/2025”,
“saldo_vencido”: 580.80,
“dias_vencido”: 66
}
],
“cuerpo_email”: “Estimado Francisco Ruiz Gutierrez,\n\nSe han identificado clientes con saldos pendientes de pago:\n\n- MOTUM AUTOMOCION SL: 163.35 €, vencimiento 19/04/2025, 17 días vencido\n- GRUYSERV ELEVACION, S.L.: 580.80 €, vencimiento 01/03/2025, 66 días vencido\n\nPor favor, tome las medidas necesarias para contactar con los clientes y gestionar el pago.\n\nLe deseo una buena semana.\n\nSaludos cordiales,\n\nDepartamento de Créditos Iberti”
}
],
“resumen_credito”: {
“resumen_plano”: “Resumen de clientes con saldo vencido:\n\n- Comercial: Francisco Ruiz Gutierrez\n - Cliente: MOTUM AUTOMOCION SL, Monto pendiente: 163.35 €, Días vencido: 17\n - Cliente: GRUYSERV ELEVACION, S.L., Monto pendiente: 580.80 €, Días vencido: 66\n\nTotal de clientes pendientes: 2”
}
}

The Problem I’m Facing:

  • Output as Long String:
    Even though the module is configured to return JSON with parsing enabled, Make keeps treating the response as a Long String instead of a collection. This means I can’t directly access {{3.result.avisos}} or {{3.result.resumen_credito}}.

  • Manual Parsing Attempt:
    When I try to use a JSON Parse module to fix this, it returns an error indicating that the result parameter (Long String) is not valid for parsing.

What I’ve Tried:

  • I have reviewed multiple forum threads, including solutions that suggest using parseJson() in a Set Variable module or cleaning line breaks and invisible characters before parsing.

  • I’ve also attempted to adjust the system messages to explicitly force pure JSON responses without additional text, but so far without success.


What I Hope to Achieve:

  • I want Make to automatically treat the ChatGPT module’s output as a structured JSON that I can directly map as a collection in subsequent modules, without the need for additional parsing steps.

Has anyone else faced this issue or found a reliable way to force ChatGPT to return a pure JSON object that Make will correctly interpret as a collection?

Thanks in advance for your help! :blush:

OK! Solved! Max completion tokens were not enough. After increase all works fine!