IF and Switch
Branching nodes: send items down different paths based on a condition.
Last updated
Analogy
if/else and switch, drawn as forks in the road.
In an agent
Typical use: if the agent says risk is high, alert the tech lead; otherwise post to the normal channel.
Questions people ask
How do I branch a workflow in n8n?
Use the IF node for a yes or no condition and the Switch node for several cases. Each sends items down a different path based on their data. For example, an IF node can check whether the agent rated a pull request as high risk and route it to a different Slack channel.
How do I route an agent's result in n8n?
Have the agent return structured output, such as a risk field with low, medium or high. Then add an IF or Switch node that reads that field from $json and sends each case down its own path: alert the tech lead for high risk, post to the normal channel otherwise.