Code Block Error

Is there any problem in the Code Block in the last few days.
Even simple Javascript code is not working.
All variables in my skill are returning “0” values

Finally I tried with a simple Javascript code:

var dummy = 5;
Speak {dummy}
And it is returning 0.

image

image

remove “var” and also you need to create a variable “dummy” as a voiceflow variable.

Thanks kun.

Removed the “var” from the script code and it works.

  1. this is a significant change. Is there any change logs, when this was pushed, since the old code was working a week ago. Would like to know of any major changes like this, as my entire skill stopped working

  2. is there are any reason why, standard Javsacript syntax “var x”, has been changed not to include “var”. Would b helpful to know

remove “var” and also you need to create a variable “dummy” as a voiceflow variable.

And why did you do that?
Few weeks ago my skill worked like a charm and now I should rework my code.

I’m not sure if this has been changed or not, but as my understanding until now:

  • variables in Voiceflow and variables in Code Block seems to have different scope.
  • define a variable in code block with “var” means that its scope is limited in Code Block.
  • you can access voiceflow variables from inside of code block and in that case you don’t need to use “var”. voiceflow variables are like more global than code block’s.
  • you cannot access variables defined in code block with “var” from outside of Code Block without defining it as Voiceflow variables.

For me, “var” is for initializing variables used in code blocks, not for variables in Voiceflow. If you wanna use variables in Voiceflow such as in Speak Block, it should be defined in variables menu and initialized in set block. IMO.