How to create conditional workflows with switches

:wave: Hello n8n community!

If you’re familiar with using paths in Zapier or routers in Make but haven’t mastered switches for directing data in workflows, this < 3 minute video will guide you on how to use them effectively.

:pray: Thanks to @bartv for alerting me to this part of the forum!

7 Likes

You’re welcome, Colleen :slight_smile: Thanks for making such a useful tutorial!

2 Likes

Great video, if you are going to do a whole series of these they will attract much attention I think. :slight_smile:

One tiny note, the switch node as was shown in the video is fairly new, so would be great to note this for people looking at it on old versions of n8n and getting confused. :slight_smile:

3 Likes

Great vid! Switches are awesome. I love how you can use them for menus in Telegram bots for example, where the /command can be checked using ā€˜String starts with’ and then the /command as value. Also, if there is no /command, you could have a ā€˜fallback’ route that handles any other behaviour.

Thank you @BramKn! :pray:

Had not thought about it from the point of view of people using older versions.

1 Like

Thank you for the feedback and sharing how you like to use switches, @codewulf0. :grinning:

I am using Switch in a scenario that can fire up to four routes at once, but they never fire at the same time. Are there any configurations that I should change, or should I use something else, or is it as it is?

Not sure I understand the question — I do notice in my workflows that each item going through travels at a different rate. Not sure if that’s what you are seeing or not.

If you are then needing to combine data again elsewhere in the flow, you can look at the merge node.

That’s exactly what I needed. I was not aware of the merge node. Thanks for that.

1 Like

You’re welcome! Glad that solves the issue. There are a few settings with merge – I found playing around with it helped me. I often set merge to ā€œCombineā€ and ā€œCombine by Position.ā€

1 Like

@colleen

Great video! I’ve been using switches in my workflows, but wonder what to do if there are too many. Think a never ending case statement. would you switch to a code node instead? I actually have a workflow that is going to continue growing and might need to adjust at some point :slight_smile:

Best,

Robert

@rbreen - I’d maybe take a step back and see if your workflow is trying to do too much. Or if the logic can be broken down in some other way. Code node may also be the right decision.

Other thoughts: Would an AI node make sense? Depending on how you set things up, you can get structured data back for use later in flows or possibly get at whatever you are trying to achieve with your switch set-up.

1 Like