MoDaQui
MoDaQui4w ago

JSON response to text (string)

Hey guys, I want to display the full JSON response from my Shopify Storefront API call inside a Voiceflow variable so that my AI agent can access and read the product data. The API call works fine in the Test Request, I can see the product data (title, description, image, price, etc.). However, when I capture the response into a variable (e.g. {rawProducts}), the variable ends up empty ([]) instead of showing the full JSON content. Solutions that I've already tried: 1. Capturing data.products.edges directly into {rawProducts} or with response 2. Using JSON.stringify(rawProducts) in a Set block 3. Testing with different variable types (array, string, object) So how can I correctly capture the entire JSON response from my Shopify Storefront API into a Voiceflow variable, so that it’s not empty and my AI agent can actually access the product information, please?
4 Replies
Tico | Voiceflow Assistant
Here’s what usually trips people up 👇 1. In the Capture Response field you must prefix the path with response.
For a Shopify Storefront GraphQL call the JSON you see in the preview looks like:
{
"data": {
"products": {
"edges": [ ... ]
}
}
}

{
"data": {
"products": {
"edges": [ ... ]
}
}
}


So the correct path to the array of products is:
response.data.products.edges

response.data.products.edges

(or response if you really need the whole object). 2. Map that path to a Voiceflow variable whose type can hold what you’re storing: • For the whole object → create the variable as object (or string if you plan to JSON-stringify it). • For just the edges array → create the variable as array. 3. Test again – the variable should now be populated. If you still want the entire payload as a single string for your AI step, add a Set (or Function) step right after and do:
{rawProductsString} = JSON.stringify({rawProducts})

{rawProductsString} = JSON.stringify({rawProducts})

Now the assistant can read it as plain text. Common reasons it shows []: • The path was entered without the leading response. • The variable’s type doesn’t match (e.g. saving an array into a string variable). Doc reference: “A path always starts with response followed by the desired mapping path.” https://docs.voiceflow.com Give that a try and your product data should come through intact! 👍
MoDaQui
MoDaQuiOP4w ago
Tried that and it still looks like that
No description
MoDaQui
MoDaQuiOP4w ago
No description
No description
No description
No description
MoDaQui
MoDaQuiOP3w ago
Help please someone ???

Did you find this page helpful?