Share feedback, ideas and get community help

Updated 11 months ago

How to set multiple variables in one go?

Using the 'Set Variable' or the 'Script' blocks, how can i set multiple variables, in one go.

Example, i a Set Variable block:
Plain Text
const a=1;
const b=2;

{{sum}} = a + b;
{{product}} = a * b;

return true;

Is it possible to set multiple variables, sum and product in this way?

If not, what's a workaround for now?
L
A
S
5 comments
I´d like to do it as well. But I think it´s not possible for now.
Yup, it is not possible right now but I did have a talk with Baptiste that voiceflow allows you to set multiple variable in Script Block..

Workaround: Save all the variable values as an array example:
Plain Text
const a=1;
const b=2;

let sum = a + b;
let product = a * b;

return [sum, product];


and then create 2 more Set Variable block as assign the value from array to you {{sum}} and {{product}} variable..

issue with this workaround?
  • must remember the index for each variable (you can use json key and value i guess too)
  • n*1 blocks for the amount of variables you need to set 😅
@Abdullah Awesome
This still necessitates creating a Set Variable block for each and every variable that needs to be set.
yes hence called the workaround 😅
Add a reply
Sign up and join the conversation on Discord