Skip to content

Conditional Routing

Sudhanshu edited this page Nov 11, 2026 · 1 revision

Conditional Routing

flowchart TD
 START([START]) --> ADD["Add_Node: input + 10"]
 ADD --> ROUTER{"number > 50?"}
 ROUTER -->|Yes: multiply| MUL["Multiply_Node: number * 2"]
 ROUTER -->|No: subtract| SUB["Subtract_Node: number - 5"]
 MUL --> END([END])
 SUB --> END
Loading

Source logic

route_based_on_value(number) returns multiply when the post-addition state is greater than 50, otherwise subtract. Input 45 becomes 55 then 110; input 20 becomes 30 then 25.

The router is attached via builder.add_conditional_edges("Add_Node", route_based_on_value, {...}), and each branch ends at END.

Change the threshold or provide additional input values to test routing, but keep branch keys and mapping synchronized.

Clone this wiki locally