Skip to main content
Runchat has two routing nodes for building workflows that take different paths under different conditions. Search for them in the node picker under Tools. Switch routes one input to one of two outputs based on a boolean. Router routes a list to multiple named outputs.
The Switch and Router nodes on the canvas

Switch

The Switch node takes a switchVal (boolean) and enables one of two outputs:
  • When switchVal is on, trueVal is enabled and downstream nodes update.
  • When switchVal is off, falseVal is enabled and downstream nodes update.
Nodes wired to the disabled output do not update.

Driving the switch with an Agent

A common pattern is to control the switch with a language model. Frame your prompt as a yes/no question, like “is this image suitable for a portfolio?”. In the Agent node’s More menu, set Output format to Custom schema and define a schema with a single boolean field, such as suitable. Then turn on Spread output so the field becomes its own output, and wire it into switchVal. This lets the workflow react to subjective conditions without you having to write classification logic.
An Agent node with a boolean schema field wired to a Switch's switchVal input

Driving the switch with code

When the condition is empirical, use a Code node that returns a boolean. This works well for:
  • Checking whether a string equals an expected value
  • Confirming whether you have data
  • Checking whether a key exists in an object
  • Comparing a value to a threshold
You can use this to gracefully handle errors, send notifications, or fix missing data before the workflow continues.

Router

The Router node is a Switch for lists. It takes a list of values and a matching list of output parameter names, and sends each value to the output with the matching name. Generate the parameter name list with an Agent or Code node, one name per item in your data list. To disable a particular output (the way Switch does), pass null for that item.

Next steps