Hi everyone, long time retool users and early workflow user. I am kinda stuck on how to do something in workflows which I am manually doing in a retool app now. I find myself sandbox test as an app first and than build workflows from that.
Basically I am filtering a product catalog via snowflake, I want JS to loop through the data and trigger 2 API calls. They are using AI to do some writing. From there I want the final add_product api call to add the product to our ecommerce store using our API where it takes some values from the snowflake data set as well as the values from ai and ai_meta API calls.
Anyone done something similar and could help steer me in the right direction?
Hi @seandawes Welcome to workflows! Thanks for reaching out.
It looks like you'll want to use a loop block, and in the loop, call those 3 queries. I would suggest making ai, ai_meta, and add_productfunctions (you can add those in the lefthand menu) and then have the JS block call them. e.g. the JS block could look like
for (const row of snowflake.data) {
const a = await ai(..)
const b = await ai_meta(..)
await add_product(b.data)
}
Let me know if that helps! Happy to take another look. Also, I checked internally, and we're actually working on an easier way to do this, so keep an eye out for workflows updates later in the quarter
But for the JS loop block I am unsure how to pass the results of each api call back to the final function which is the add product api call
for (const row of snowflake.data) {
const a = await function_ai(row.CLEANED_TITLE)
const b = await function_ai_meta(row.CLEANED_TITLE)
await function_add_product(?)
}
And in the function which is the add product api call how would I reference variables from the row loop from my initial SQL data table as well as the 2 openai API calls in the loop?