Turning ChatGPT response into array

Hello!

I am trying to automate order collection from my shop. We use order sheets because our product is configurable, customer can select color, size, and many other choices. I am using pdf.co to read order’s sheet values. Then i am processing them to JSON and send them to chatGPT to sort order and collect important information. As a response i get long string build like:

[
{
“System”: “Disting”,
“Kolekcja”: “Astre”,
“Model”: “21”,
“Kolor”: “antracyt”,
“Rodzaj progu”: “Niski”,
“Kolor progu”: “nox”,
“Rozmiar”: “90N”,
“Kierunek”: “Prawe”,
“Otwieranie”: “ONZ”,
“Szklenie”: “ustro”,
“Okucia klamka”: “komplet okuc ST Standard”,
“Okucia pochwyt”: “pochwyt Profile 120 cm inox”,
“Akcesoria”: “elektrozaczep”,
“Ilosc”: “1”,
“Uwagi”: “czarna oscieznica”
},
{
“System”: “Disting Plus”,
“Kolekcja”: “Ezio”,
“Model”: “12”,
“Kolor”: “antracyt struktura”,
“Rodzaj progu”: “Wysoki”,
“Kolor progu”: “Inox”,
“Rozmiar”: “80N”,
“Kierunek”: “Lewe”,
“Otwieranie”: “ODW”,
“Szklenie”: “satyna”,
“Okucia klamka”: “komplet okuc ST Standard”,
“Okucia pochwyt”: “pochwyt Profile 170 cm inox”,
“Akcesoria”: “poszerzenie 5 cm”,
“Ilosc”: “2”,
“Uwagi”: “czarna ościeżnica”
},
{
“System”: “Basic”,
“Kolekcja”: “Figaro”,
“Model”: “12”,
“Kolor”: “bialy”,
“Rodzaj progu”: “—”,
“Kolor progu”: “Inox”,
“Rozmiar”: “80E”,
“Kierunek”: “Prawe”,
“Otwieranie”: “ONZ”,
“Szklenie”: “satyna-paski”,
“Okucia klamka”: “komplet okuc ST Standard”,
“Okucia pochwyt”: “pochwyt Profile 170 cm patina”,
“Akcesoria”: “podwalina 20 cm”,
“Ilosc”: “3”,
“Uwagi”: “ościeżnica w kolorze\n czarnym”
},
{
“System”: “Normal”,
“Kolekcja”: “Liberto”,
“Model”: “12”,
“Kolor”: “dab zloty”,
“Rodzaj progu”: “—”,
“Kolor progu”: “Inox”,
“Rozmiar”: “90E”,
“Kierunek”: “Lewe”,
“Otwieranie”: “ODW”,
“Szklenie”: “czarny antisol”,
“Okucia klamka”: “komplet okuc ST Standard”,
“Okucia pochwyt”: “pochwyt Profile 120 cm patina”,
“Akcesoria”: “samozamykacz”,
“Ilosc”: “4”,
“Uwagi”: “osc. czarna”
},
{
“System”: “Normal Plus”,
“Kolekcja”: “Mario”,
“Model”: “12”,
“Kolor”: “dab turner”,
“Rodzaj progu”: “—”,
“Kolor progu”: “Patina”,
“Rozmiar”: “100E”,
“Kierunek”: “Prawe”,
“Otwieranie”: “ONZ”,
“Szklenie”: “loft 01”,
“Okucia klamka”: “komplet okuc ST Standard Czarny”,
“Okucia pochwyt”: “pochwyt Profile 170 cm patina”,
“Akcesoria”: “wizjer”,
“Ilosc”: “5”,
“Uwagi”: “czarna oscieznica”
}
]

Each object in array is one position from PDF. (find it attached)
ChatGPT returns it as Long String and i need to turn it into array of objects to loop through and fill airtable columns with data.

Please help me to do that!
Zamówienie drzwi Zewnętrzne test auto.pdf (271.9 KB)

Hey @Tymoteusz_Weglorz, welcome to the community! :wave:

This is doable using the JSON - Parse JSON module :slight_smile:

Simply wrap the response from ChatGPT to something like what’s visible below and work with it further down in the scenario.

{"objects": MAP_GPT_RESPONSE_HERE}

PS: I don’t know if the quotes(“Prawe” vs “Prawe”) in your question are the actual ones that ChatGPT returns, if so, I’d modify the prompt and specify to use these “” quotes. Alternatively you can use the replace function in Make to get rid of those

3 Likes

Amazing, thank you Dan.

2 Likes