If you're working with conditional components using JSON UI schema, you might come across this frustrating error:
INVALID_PROPERTY_VALUE: Expected single operand to be a boolean.
Quick Fix
The condition in an If component must resolve to a boolean, not a string, number, or undefined variable. Here’s how to fix it:
{
"type": "If",
"condition": "${data.isActive === true}",
"then": [...]
}
Or simply:
{
"type": "If",
"condition": "${Boolean(data.isActive)}",
"then": [...]
}
Why This Happens
The error usually appears when:
You’re referencing a string or undefined value directly:
"condition": "(${data.string_value})"
You hardcode a literal non-boolean value:
"condition": "true"
Both are syntactically valid strings, but the system expects a dynamic expression that evaluates to a boolean.
What You Should Do Instead
Use logical comparisons or explicit conversions:
Incorrect | Correct |
"condition": "(${data.string_value})" | "condition": "${data.string_value === 'yes'}" |
"condition": "true" | "condition": "${true}" |
"condition": "(${data.number})" | "condition": "${data.number > 0}" |
"condition": "(${data.flag})" | "condition": "${Boolean(data.flag)}" |
Pro Tip
If you're unsure what a variable holds, log it out or add a Text component temporarily using:
{
"type": "Text",
"text": "${JSON.stringify(data)}"
}
This way, you can safely debug what data.xyz actually contains before using it in a condition.
Treat all conditions as JavaScript expressions inside "${...}". If you’re not explicitly returning true or false, you’re likely to hit this validation error. Always test your expression’s output and make sure it resolves to a boolean.
For more troubleshooting insights related to WhatsApp Business API, check out heltar.com/blogs.