Skip to content
Getting GSheets dat...
 
Notifications
Clear all

Getting GSheets data to OpenAI as a JSON string - is it possible?

20 Posts
4 Users
0 Reactions
7 Views
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

Hi everyone,

I’m encountering a technical hurdle with an integration on callin.io and I'm hoping for some community assistance.

Use case:
I'm utilizing the GSheets > Make an API call module to pull data from two columns in a Google Sheets file. My objective is to construct a JSON object formatted like this:

json
{
"output": [
{ "key": "colA", "value": "colB" },
{ "key": "colA", "value": "colB" },
...
]
}

Where:

  • Values from column A in Google Sheets will serve as the "key"
  • Values from column B will be the "value"

Planned strategy:
The JSON generation is intended to be handled directly by the OpenAI module to streamline the process.

Issue encountered:
The OpenAI module requires string inputs, but the data received from the GSheets module is provided as a nested array. This mismatch is causing the problem.

I attempted to use an Iterator to process the data, but it only seems to return the first key-value pair and doesn't iterate through all the elements from GSheets. I suspect the issue might be related to the array's structure or how the iterator is handling it.

Goal:
My aim is to correctly convert the data extracted from GSheets into a string that matches the specified JSON structure and pass it appropriately to the OpenAI module.

Bonus:
Seeking assistance from the community for this challenge — I could really use some help resolving this before I get too stuck!

:exploding_head:

Thanks in advance for any suggestions or help!

 
Posted : 16/04/2025 3:06 pm
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

Hello everyone, I'm having trouble with this and could use some guidance.

 
Posted : 17/04/2025 2:28 pm
Donald_Mitchell
(@donald_mitchell)
Posts: 36
Eminent Member
 

I'd suggest using an Iterator on your Array that comes from Google Sheets, followed by an aggregator.
If you need to pass text to OpenAI, use the Text Aggregator.
If you need to pass JSON, use the JSON aggregator.
You could also try using a Transform to JSON module on the array instead of the Iterator-Aggregator combination.

It's a bit challenging to give a definitive answer without a completely clear understanding of how your data needs to be formatted before it goes into OpenAI.

Also, I'm curious why you're using an API call for Google Sheets and not a built-in function?

 
Posted : 17/04/2025 2:52 pm
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

I had previously attempted to use the iterator, but it only seems to extract the initial ‘key’ and ‘value’ from the nested array.

The method of data extraction from Google Sheets is not critical, as I will be processing it with OpenAI afterward.

I am utilizing the “Make an API call” module because my goal is to automate the process. Using the pre-configured modules would necessitate manually selecting the different spreadsheets each time a new one is created.
Therefore, I am unable to map all the fields within the nested array.

If I attempt to use the Text Aggregator directly, it results in an error.

 
Posted : 17/04/2025 3:44 pm
Donald_Mitchell
(@donald_mitchell)
Posts: 36
Eminent Member
 

You need to map Body.Array from Google Sheets into your Iterator.
10.Body[] is a Collection, and you cannot Iterate that. You must iterate on the nested array.

Yes, it matters, because you want to convert what’s coming out of Google Sheets into something compatible for input into OpenAI.

So let’s say OpenAI needs to accept JSON. In that case you need:
Google Sheets → Iterator → JSON Aggregator → OpenAI

Alternate way that might work, if OpenAI accepts it:
Google Sheets → Transform to JSON → OpenAI

 
Posted : 18/04/2025 3:34 am
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

I've been looping through 10.Body[], but it still only retrieves the initial array. I suspect there might be an issue on callin.io's side.

I've spent days on this, and it seems unresolvable.
If you're interested in trying it yourself (you're definitely more skilled at this than I am), the process is straightforward:

  1. Create a Google Sheets document structured like this:

  2. Utilize Gsheets → Make an API call

  3. Incorporate an Iterator

If you manage to get this working, you'd be a lifesaver!

:superhero:t3:

Thanks for your help.

 
Posted : 18/04/2025 8:16 am
Donald_Mitchell
(@donald_mitchell)
Posts: 36
Eminent Member
 

10.Body is a collection; you should not iterate directly over it.

Instead, iterate over 10.Body.array.
Locate your array within the Google Sheets output and then drag the 10.Body.array into the Iterator module.

 
Posted : 18/04/2025 10:21 am
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

Unless I'm mistaken, it doesn't seem to be there.

My apologies if I'm not grasping it correctly

:frowning:

 
Posted : 18/04/2025 10:28 am
samliew
(@samliew)
Posts: 293
Reputable Member
 

Hi Andy, thanks for reaching out and apologies for the delayed reply. I've been occupied with client work over the last few days, but I anticipate having some availability mid-next week to review your request.

Should you need immediate assistance, my profile contains links to helpful resources. These include an AI trained on my 10k+ forum responses, or you can explore my past posts for answers to similar inquiries.

Thanks,
@samliew

 
Posted : 18/04/2025 2:11 pm
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

I've already searched but couldn't find a solution. Could you please assist me?

 
Posted : 18/04/2025 2:17 pm
Donald_Mitchell
(@donald_mitchell)
Posts: 36
Eminent Member
 

That's odd, I was referring to the “values” array that you had highlighted in your initial post.

Perhaps you could try {{10.body.values}}?

 
Posted : 18/04/2025 2:32 pm
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

I attempted that, but it didn't yield any results. Is this not possible to achieve?

:exploding_head:

 
Posted : 18/04/2025 2:42 pm
Donald_Mitchell
(@donald_mitchell)
Posts: 36
Eminent Member
 

It might be a display issue within callin.io. Have you attempted this within the Iterator module?


{{10.body.valueRanges[1].values}}

And in your aggregator, retrieve the values using this syntax:


{{get(##.value; #)}}

Where ## refers to the module number of your Iterator, and # represents the column number you wish to extract from the current row being iterated. For instance, 1 corresponds to Column 1.

 
Posted : 19/04/2025 3:25 am
Andy4
(@andy4)
Posts: 11
Active Member
Topic starter
 

It's not functioning, and there's nothing to do.

This is unbelievable!

 
Posted : 22/04/2025 6:37 pm
samliew
(@samliew)
Posts: 293
Reputable Member
 

To help us understand your scenario, please provide the following:

1. Relevant Screenshots

Please share screenshots of your scenario, any error messages, relevant module fields, and filters you are concerned with. This will greatly assist other community members in understanding your situation.

2. Scenario Blueprint

Kindly export your scenario blueprint file. This will enable others to see the mapped variables within the module fields. You can find the "Export Blueprint" option by clicking the three dots at the bottom of the scenario editor.

3. Output Bundles of Modules

Please provide the output bundles from your modules. You can achieve this by running the scenario (or by retrieving them from the scenario History tab). Then, click the white speech bubble located in the top-right corner of each module and select "Download input/output bundles".

Sharing the input/output bundles will allow others to replicate your scenario's behavior, even if they don't use the external service.

 
Posted : 23/04/2025 3:11 am
Page 1 / 2
Share: