šŸŽÆ Question about using variables in Script block

Hi everyone! I'm working with a Script block in Typebot and I need to use some variables previously collected in the flow, like numeroInterno and codigoPago. I'm trying to access them in the script like this: console.log("Internal Number:", numeroInterno); console.log("Payment Code:", codigoPago); But I get this error: ReferenceError: Cannot access 'numeroInterno' before initialization šŸ¤” What's the correct way to access flow variables inside a Script block? Do I need to declare them or use a specific syntax to make them available as JavaScript variables? Any help or working example would be greatly appreciated šŸ™
2 Replies
Anthony
Anthonyā€¢2w ago
Hello Fernando, In most fields in Typebot, you'll find this {} icon you can click on to insert a variable in it. The other quicker method is simply to wrap your variable name around {{and }}, such as {{myvariable}}. So if you want to console log variables, you'd have to write:
console.log("Internal Number:", {{numeroInterno}});
console.log("Payment Code:", {{codigoPago}});
console.log("Internal Number:", {{numeroInterno}});
console.log("Payment Code:", {{codigoPago}});
Make sure "Execute on client" is checked for the logs to appear in your browser's console. Hope it helps!
No description
Fernando Carmine
Fernando CarmineOPā€¢2w ago

Did you find this page helpful?