Dynamic Data Routing with Conditional Logic
detail.loadingPreview
This workflow demonstrates powerful conditional logic, allowing you to route incoming data items to different processing paths based on their specific values. It's perfect for workflows requiring dynamic decision-making and tailored actions.
About This Workflow
This n8n workflow showcases a fundamental pattern for intelligent automation: dynamic data routing. Starting with a simple manual trigger, the workflow first uses a Function node to generate a series of data items, each with a unique id. The core of the workflow is the Switch node, which acts as a decision-maker. It evaluates the id of each incoming item and directs it down a specific branch. Each branch then uses a Set node to assign a distinct 'name' value, illustrating how different actions can be performed based on the initial data. This setup is invaluable for processing diverse datasets or implementing complex business rules.
Key Features
- Conditional Data Routing: Efficiently directs data items to different branches based on specific conditions using the
Switchnode. - Flexible Data Generation: Utilizes the
Functionnode to create custom data payloads for testing and dynamic input. - Item-Level Processing: Each data item is processed independently through the conditional branches, allowing for granular control.
- Easy Data Transformation: Demonstrates basic data manipulation with the
Setnode to apply different values based on routing.
How To Use
- Start the Workflow: Execute the "On clicking 'execute'" node manually to trigger the workflow.
- Inspect Function Node: Review the
Functionnode's code to understand how it generates a list of items withidvalues (0, 1, 2). You can modify this code to simulate different data inputs. - Configure Switch Node: The
Switchnode is pre-configured to evaluate{{$node["Function"].json["id"]}}.- Rule 0: Routes items where
idequals0to the first output (connected to "Set"). - Rule 1: Routes items where
idequals1to the second output (connected to "Set1"). - Rule 2: Routes items where
idequals2to the third output (connected to "Set2"). - The fallback output routes any other
idvalues to "NoOp".
- Rule 0: Routes items where
- Customize Set Nodes: Each "Set" node (Set, Set1, Set2) assigns a different 'name' value ("n8n", "nodemation", "nathan"). You can modify these to perform any desired operation specific to that data path.
- Extend Functionality: Connect more nodes to each output of the
Switchnode to build out complex, conditional automation flows.
Apps Used
Workflow JSON
{
"id": "8363125b-2079-4423-9f04-d790807bfaa9",
"name": "Dynamic Data Routing with Conditional Logic",
"nodes": 16,
"category": "Operations",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 8363125b-2079...
About the Author
Crypto_Watcher
Web3 Developer
Automated trading bots and blockchain monitoring workflows.
Statistics
Related Workflows
Discover more workflows you might like
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.
On-Demand Microsoft SQL Query Execution
This workflow allows you to manually trigger and execute any SQL query against your Microsoft SQL Server database. Perfect for ad-hoc data lookups, administrative tasks, or quick tests, giving you direct control over your database operations.
Automate Getty Images Editorial Search & CMS Integration
This n8n workflow automates searching for editorial images on Getty Images, extracts key details and embed codes, and prepares them for seamless integration into your Content Management System (CMS), streamlining your content creation process.