-
Goal: Have an API enrichment loop through the values of each row in a table and update the table back with the results from the API.
-
Steps:
What's working
- Dynamically import a file upload to a table
- Make an API call to an external platform when a trigger button is selected
- Update the response back in the table.
What's not working
- While I'm able to make an API call, only an API call is made for the first row.
- While I'm able to update the response back to the table, it's populating the answer for the first API call to all rows instead of just the first row.
I want to be able to loop through the rows of the table and make an API call for each website, and then have the output updated back to the GPT Scraper column of the table.
- Details:
API Call
{"instructions":"{{gptScraperForm.data.gptInput }}","linkSelector":"a[href]","maxPagesPerCrawl":0,"model":"gpt-4o","openaiApiKey":"xxx","proxyConfiguration":{"useApifyProxy":true},"removeElementsCssSelector":"script, style, noscript, path, svg, xlink","removeLinkUrls":false,"saveSnapshots":true,"schema":{"type":"object","properties":{"title":{"type":"string","description":"Page title"},"description":{"type":"string","description":"Page description"}},"required":["title","description"]},"startUrls":[{"url":"{{table1.selectedRow.Website}}"}],"useStructureOutput":false,"includeUrlGlobs":[],"excludeUrlGlobs":[],"maxCrawlingDepth":99999999,"initialCookies":[],"temperature":"0","topP":"1","frequencyPenalty":"0","presencePenalty":"0","pageFormatInRequest":"Markdown","skipGptGlobs":[],"dynamicContentWaitSecs":0}```
Transformer
function transformData(data) {
const gptResults = data.map(item => item.answer).join('\n');
{{ gptScraperResults.setValue(gptResults) }};
return gptResults;
}
return transformData(data);
return da```
Screenshots
API Call
This successfully makes the API call and returns the correct data, but it is only taking the website from the first row. I want it to call the API for each website in the table rather than just the first website.
Success Event Handler
Dynamic Column Value from API
This is taking the API result from the first row and populating the first result to all rows.