flat-fuchsia•2y ago
JavaScript card error
Hi, I'm creating an appointment set bot and I'm having some issues with the javascript card in Voiceflow. I want to take a date that the user entered (stored in the "userFormattedDate" variable) and check if the date inside the variable is a weekend. If the date is a weekend the user will be directed to 2 other paths "Saturday" or "Sunday", if the date is a normal day of the week the user must go to the default path.
For this I am using the following code:
function checkFinalDeSemana(userFormattedDate) {
var dayOfWeek = userFormatedData.getDay();
if (dayOfWeek === 6) {
return 'Saturday';
} else if (dayOfWeek === 0) {
return 'Sunday';
}
}
My problem is that the code doesn't recognize when it's the weekend, it always goes to the default path and retrieves the "no variable change" message. I think my code is correct, which leads me to imagine that the problem is related to some interaction between voiceflow and js.
0 Replies