šÆ 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
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:
Make sure "Execute on client" is checked for the logs to appear in your browser's console.
Hope it helps!