Switch Node
What does it do?
Routes to different nodes based on the value of an input. Works like a switch/case statement — checks the input against a list of cases and routes to the matching node. The input is converted to a string and trimmed before matching.
1. Syntax
<node_name>:
type: func
func_type: system
func_id: switchNode
params:
input: "<value to check>"
cases:
"<case_1>": <node_for_case_1>
"<case_2>": <node_for_case_2>
empty: <node_when_input_is_empty>
on_complete: <fallback_when_no_case_matches>
required params
typetype of the nodefunc_typehere it will be a system functionfunc_idwhat function are we calling (switchNode)params.inputthe value to evaluate — typically a data injection expression (converted to a string and trimmed before matching)params.caseskey-value map where keys are the possible values and values are node names to route to (minimum 1 entry)on_completerequired on everyfuncnode (YAML validation). ForswitchNode, it is also the fallback when there is noon_failure(see below)
optional params
on_failureif set, used as the fallback when no case matches (or when input is empty/falsy andemptyis not set). If omitted,on_completeis used for those cases — so for routing purposes,on_failureandon_completeplay the same role;on_failurewins when both are presentparams.emptynode to route to when the input is empty, null, or undefined (if omitted, empty input uses the same fallback as a non-matching value)departmentassigns the chat to a departmentagentassigns the chat to a specific agent (email address or CRM ID as defined in the Texter agents manager)
Routing logic
- If input is empty/falsy → routes to
emptyif set, otherwise the fallback (on_failureif set, elseon_complete) - If input matches a case key → routes to that case's node
- If input doesn't match any case → routes to the fallback (
on_failureif set, elseon_complete)
2. Examples
Route by stored customer type
abandoned_switch_on_customer_type:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:store.customer.type%"
cases:
"new": abandoned_store_messages
"existing": handoff
on_complete: abandoned_store_messages
Route by account ID (multi-branch routing)
check_account_id:
type: func
func_type: system
func_id: switchNode
params:
input: "%chat:channelInfo.accountId%"
cases:
"972549947692": store_main_details
"972545230925": store_midtown_details
"972587400330": store_ono_details
"972547344476": store_modiin_details
on_complete: store_main_details
Route by API response count
check_if_customer_found:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:node.get_customer_details.response.total%"
cases:
"0": ask_if_customer
on_complete: store_existing_customer_details
Route by CRM field (boolean)
check_covo_field:
type: func
func_type: system
func_id: switchNode
params:
input: "%chat:crmData.queryResult.COVO%"
cases:
"true": covo_ask_for_feedback
"false": noop_resolved
on_complete: noop_resolved
Route by language
smart_resolved:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:store.language%"
cases:
"hebrew": smart_resolved_he
"english": smart_resolved_en
"russian": smart_resolved_ru
on_complete: smart_resolved_he
Route by HTTP status code with empty fallback
switch_by_value_check_if_failed:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:node.start_get_costumer_details.statusCode%"
cases:
"404": new_client_menu
empty: store_value_exist_client
on_complete: store_value_exist_client
Route by branch ID (from a choice node)
switch_treatment_menu_by_branch:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:store.branchId%"
cases:
"3": midtown_which_treatment
on_complete: general_which_treatment
Route by stored lead status with empty
check_new_lead:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:store.newLead%"
cases:
"true": open_lead_handoff
empty: no_lead_handoff
on_complete: no_lead_handoff
Prefer on_failure for the no-match destination (optional)
When you want the “no case matched” node to be explicit, set on_failure. It overrides on_complete for that fallback; on_complete is still required on the node for validation.
route_by_status:
type: func
func_type: system
func_id: switchNode
params:
input: "%state:store.status%"
cases:
"active": active_flow
on_complete: default_flow
on_failure: default_flow
tip
Case keys are matched as strings. Always quote keys in YAML: "hebrew": node_name, not hebrew: node_name (unquoted keys can be parsed incorrectly).
tip
The input is converted to a string and trimmed before matching. null, undefined, and empty strings are all treated as empty.