denglander
denglander4mo ago

Condition step won't work correctly

I'm having a very frustrating issue with a condition step. In a previous step, I am setting a number of different variables. Here is an example from a run debug: "metadata": { "variables": { "candidate_1_city": "Brooklyn", "candidate_2_city": "Brooklyn", "candidate_3_city": "Brooklyn", "candidate_1_desired_schedule": "Part-time", "candidate_2_desired_schedule": "Open to any work schedule", "candidate_3_desired_schedule": "Per-Diem", "candidate_1_state": "NY", "candidate_2_state": "NY", "candidate_3_state": "NY", "candidate_1_languages": "English", "candidate_2_languages": "English", "candidate_3_languages": "English", "candidate_1_discipline": "Personal Care Aide (PCA)", "candidate_2_discipline": "Personal Care Aide (PCA)", "candidate_3_discipline": "Personal Care Aide (PCA)", "candidate_1_desired_shift": "Morning", "candidate_2_desired_shift": "Evening; Afternoon; Weekdays; Morning; Night", "candidate_3_desired_shift": "Morning; Afternoon; Evening; Night; Weekdays; Weekends", "candidate_1_care_setting": "Inpatient; Home Care", "candidate_2_care_setting": "Home Care; Inpatient", "candidate_3_care_setting": "Home Care; Skilled (nursing / assisted living)", "num_candidates": "3" } I have a condition step next which is looking to see if candidate_3_discipline is empty. I keep getting this error: { "time": 1756932611431, "type": "debug", "payload": { "ref": { "type": "node", "nodeID": "68b8a539d07704ebfbd586ba", "nodeType": "condition-v3", "diagramID": "64dbb6696a8fab0013dba194" }, "level": "warn", "message": "expression failed", "context": "Condition", "metadata": { "error": {} } } } I've tried doing this about 10 different ways with different variables but nothing is working.
3 Replies
Tico | Voiceflow Assistant
That "expression failed" warning is coming from the JavaScript expression inside the Condition step – the code can’t be parsed, so the step never evaluates to true / false and Voiceflow shows the error. A few things to double-check: 1️⃣ Make sure you write the variable name without curly-braces or quotes
// ✅ CORRECT – plain JS that returns a boolean
!candidate_3_discipline || candidate_3_discipline.trim() === ""

// ❌ Will throw – brackets are treated as part of the string
"{candidate_3_discipline}" === ""
// ✅ CORRECT – plain JS that returns a boolean
!candidate_3_discipline || candidate_3_discipline.trim() === ""

// ❌ Will throw – brackets are treated as part of the string
"{candidate_3_discipline}" === ""
2️⃣ The expression field must contain only a boolean expression – do not add a return or a semicolon at the end. 3️⃣ If you prefer the no-code option, switch the Condition to Business Logic → Builder and set: • Variable = candidate_3_discipline • Operator = is empty • Path = whatever you want to run when it’s empty Voiceflow will create the correct JS for you in the background. 4️⃣ If there are executions where candidate_3_discipline hasn’t been created yet, the expression above (!candidate_3_discipline) will still work – an undefined or empty string is treated as falsey. After fixing the expression / builder setup, run the Debugger again and the warning should disappear, with the flow taking the correct path. Docs: https://docs.voiceflow.com (→ Condition step → Expression / Builder sections)
denglander
denglanderOP4mo ago
I had tried the no code option, but that wasn't working either. I also tried what you suggested in #1, but I'm getting this error: { "time": 1756991227973, "type": "debug", "payload": { "ref": { "type": "node", "nodeID": "68b8a539d07704ebfbd586ba", "nodeType": "condition-v3", "diagramID": "64dbb6696a8fab0013dba194" }, "level": "warn", "message": "script evaluation failed", "context": "Condition", "metadata": { "code": "!candidate_3_discipline || candidate_3_discipline.trim() === """, "error": {} } } } I also tried this JS expression: candidate_3_discipline && candidate_3_discipline.trim() !== "" The variable is definitely set, but I'm still getting this: { "time": 1756991700067, "type": "debug", "payload": { "ref": { "type": "node", "nodeID": "68b8a539d07704ebfbd586ba", "nodeType": "condition-v3", "diagramID": "64dbb6696a8fab0013dba194" }, "level": "info", "message": "navigating to else path - no conditions matched", "context": "Condition" } } I'm fairly certain there's just a bug with this. Here's what I just tried: I created a set step where I'm setting the candidate_3_discipline variable to PCA. Then I have a condition step next which checks if that variable is not empty. If I start my run at this set step, the condition passes as it should. If I start at an earlier step, the condition fails. I'm still using the exact same set step where I'm manually setting the variable value. Except when I have additional steps before that running, the condition fails. Even though the variable value ends up exactly the same in both scenarios, one works and one doesn't. In the case where I start the run earlier, the condition check fails: { "time": 1756996589928, "type": "debug", "payload": { "ref": { "type": "node", "nodeID": "68b8a539d07704ebfbd586ba", "nodeType": "condition-v3", "diagramID": "64dbb6696a8fab0013dba194" }, "level": "warn", "message": "expression failed", "context": "Condition", "metadata": { "error": {} } } }
denglander
denglanderOP4mo ago
this is my condition step
No description

Did you find this page helpful?