generous-apricot
generous-apricot2y ago

Java script pads

my code is working but it won’t take the right path I have added in the recommended code to define what path to take yet it still goes to default anyone know what to do or how to fix it ?
3 Replies
Tico | Voiceflow Assistant
In Voiceflow, the JavaScript code step allows you to define custom paths and conditionally branch the flow based on your code. You can add up to 10 custom paths in a code step and give a custom name for each path. To go down a specific path, you need to call return "path_name" within your code. If nothing is returned, it will use the Default path. For example, if you have two custom paths named "victory" and "defeat", your code might look like this:
if (score > 100) {
return "victory";
} else if (score < 0) {
return "defeat";
}
// otherwise it will go down the Default path
if (score > 100) {
return "victory";
} else if (score < 0) {
return "defeat";
}
// otherwise it will go down the Default path
If your code is not taking the right path, it could be due to a few reasons: 1. The condition for the custom path is not being met. Make sure the conditions in your if/else statements are correct and being met. 2. The return statement is not correctly formatted. Ensure you're using the correct syntax: return "path_name";. 3. There might be an error in your code causing it to fail and go down the Default path. Check for any syntax errors or logical errors in your code. Remember, the Default path will be followed if your code is successfully run, and the Failure path will be followed if your code fails to run or errors during execution. For more information, you can refer to the JavaScript documentation on Voiceflow.
generous-apricot
generous-apricotOP2y ago
I already added that code and still didn’t work
curly-silver
curly-silver2y ago
Can you share your code?

Did you find this page helpful?