How can Smart Query Access Values from 2 Query Blocks

Im trying to build a workflow which basically takes products and suggests a category to apply to the product. So I have 2 main queries:

  1. Product Query
  2. Categories Options Query

I originally had a JS loop block which would iterate over my products query and send a payload to a smartQuery. In the smartQuery it would use the data from my Categories query to pick from for a supplied value of product name from my products table. I can get the smartQuery to pick the proper category if I manually supply the value in the instruction section but if I try adding {{value}} which I thought would be my product name supplied in my JS via payload it does not work.

Any ideas here?

Hey seandawes!

Your code is referencing {{value}} that was a part of a loop block.
Now that you have deprecated the loop you need to adjust the prompt and the reference.


Use this list and pick the best applicable permaling for each value from {{>x.productName)}}
- Return a list of products from loop with their corresponding permalinks

Does that help?

@stefancvrkotic Yes that helped a bit. Thank you!

Had a question though. Looks like it returns it as JSON in data as a string. How would I access that data beyond the smartQuery? I tried altering the smartquery to return an array but think I am off on how to access that data?

Note my JS is not complete

Got it to work

let jsonString =;
let aiResponse = JSON.parse(jsonString);

for (let i = 0; i < aiResponse.length; i++) {
  let prodName = aiResponse[i].productName;
  let permalinkSuggestion = aiResponse[i].permalink;

  console.log(`Product Name: ${prodName} has suggested category of: ${permalinkSuggestion} `);
1 Like

Ran into an issue using the smart block + payload method. Looks like the JS I used and JSON.parse was inconsistent in parsing the string output from the smartQuery block.

I tried instead to do the workflow in another manner which was just using a loop to iterate over my products query and make individual API calls to OpenAI. Issue I am having in this method now is it doesn't appear the prompt is able to know the data from categories as the output is not picking from that.

In my other workflow using smartquery block it has no problem doing so. Unsure what I am overlooking here.

Solution was to use JSON.stringify on my categories query

1 Like