🗨 How can I display the results of my script in the Typebot chat?
Save the result as a variable in Typebot
In your script block, make sure you're using the Typebot function setVariable() correctly:
.then(datos => {
console.log("
console.log(datos);
setVariable('facturas', datos); // save the JSON array to a Typebot variable
return true;
})
.catch(error => {
console.error(error);
setVariable('errorAPI', 'Could not retrieve data.');
return false;
}); I have a script block that successfully calls an external API and stores the result (a JSON array) using setVariable('facturas', datos);. The script works correctly and I can see the data in the console.
Now I want to display the list of results (invoices) in the chat. What's the best way to do this?
Is there a way to loop through the array and show each item?
Can I use a formatted text block or cards to display each invoice?
Should I process the array into a single string inside the script and use a single text variable?
Any examples or best practices would be appreciated!