function
Why does the function return the expected values when I run it inside the block, but in the normal flow, the values are not returned?


1 Reply
When you click “Run” in the Function-step editor Voiceflow only executes that one block and shows you the raw outputVars object that your code returns – nothing else has to be mapped, so the values appear exactly as you build them.
During a real conversation, however, the values are only kept if the Function-step is wired into your flow and the outputs are mapped to project variables:
1. Open the Function step → “Variables” tab.
2. In the Outputs section choose (or create) a flow variable for every key that your code returns in
outputVars
.
• If the key is summary
map it to something like \{summary}
in your project.
3. Make sure the step continues through a path (Default, or the custom path returned in next
) so it is actually executed.
4. Return only primitive data types – if you need to pass an array or object use JSON.stringify()
first; non-primitive values are dropped at runtime.
If the mapping is missing, the prototype inside the Function editor will still show the values, but when the assistant reaches the block there is nowhere to store them, so the variables in the rest of the flow stay empty.
Docs: https://docs.voiceflow.com (see “Function step – input & output variable mapping”).