Automate Customer Data Routing with n8n If and Switch Nodes

Struggling with manual customer data sorting? This n8n workflow expertly automates conditional routing of customer records by country and name, saving hours and minimizing errors. Learn to leverage If and Switch nodes for precise data filtering and branching.
manualTrigger
if
switch
+2
Workflow Identifier: 2409
NODES in Use: Manual Trigger, n8nTrainingCustomerDatastore, Sticky Note, If, Switch

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow sorts customer data automatically.
It fixes the problem of spending many hours sorting records by country.
When started, it gets all customers, then sends them to different paths based on country and name rules.
The result is that customers get the right messages without errors.


Inputs, Processing, and Outputs

Inputs

  • The workflow starts by fetching all customer records from a customer data source in n8n.

Processing Steps

  • Use If nodes to check if a customer’s country is “US” or if the country is empty or the name contains a keyword like “Max”.
  • Combine conditions with OR or AND by setting combination rules inside If nodes.
  • Send customer data through a Switch node to sort customers from US, CO, UK, or others into different workflow paths.
  • Add Sticky Note nodes to explain each step for easier understanding.

Outputs

  • The customer data streams branch out to correct handling steps based on filtered countries or names.
  • No customer data is lost due to the fallback route for unmatched countries.

Who Should Use This Workflow

This workflow is good for people who manage customer data but do not want hard coding or many manual steps.
Anyone who needs to send messages by region or want no mistakes when sorting records will benefit.


Tools and Services Used

  • n8n: The automation tool where this workflow runs.
  • Customer Datastore node: Fetches all customer data.
  • If nodes: Filter customers by country or name conditions.
  • Switch node: Routes customer data by selected countries.
  • Sticky Note nodes: Add explanations inside the workflow.

Beginner Step-by-Step: How to Use This Workflow in Production

Import the Workflow

  1. Download this workflow using the Download button on this page.
  2. Open your n8n editor.
  3. Click on “Import from File” and select the downloaded workflow file.

Configure the Workflow

  1. Add your credentials or API Keys for the Customer Datastore node.
  2. Change any IDs, emails, channels, folders, or tables as needed to fit your data.
  3. Check the expressions inside If and Switch nodes to match your data fields, for example:
    {{$json["country"]}

Test and Activate

  1. Run the workflow manually once using the Manual Trigger node’s “Execute Workflow” button.
  2. Verify customer data flows correctly through the branches.
  3. When satisfied, activate the workflow by toggling the Active switch in n8n.

Optionally, add a Cron node to schedule regular runs.
For more control, consider running n8n on your own server with self-host n8n.


Customizations

  • Adjust the countries in the Switch node to match your own region codes.
  • Change the text keyword in the If node to filter other names instead of “Max”.
  • Switch combination logic in If nodes between OR (any) or AND (all) to control filtering details.
  • Add new routing rules in the Switch node for more countries or different conditions.
  • Edit or add new Sticky Note nodes to keep workflow documentation up to date for your team.

Troubleshooting

Workflow returns no data after filtering

The filter conditions might not match any records.
Double-check JSON expressions used in the If nodes, like {{$json["country"]}}.
Run the workflow step-by-step and inspect outputs.

Switch node does not route data as expected

Country codes may be misspelled or case does not match exactly.
Verify spelling and capitalization in route rules.
Make sure fallback route is set to catch missing matches.

Pre-Production Checklist

  • Check the Customer Datastore node can fetch data properly.
  • Test all If node filters with actual sample data.
  • Ensure the Switch node covers all expected countries and includes fallback output.
  • Run manual tests with different datasets to confirm data flows on all branches.
  • Backup the workflow file before deploying to production.

Deployment Guide

  • Activate workflow by toggling the Active button inside n8n.
  • Schedule runs with a Cron node for automation.
  • Watch execution logs inside the n8n dashboard for errors or issues.
  • Set alerts or logs if customer data does not filter correctly.

Summary and Results

✓ Save hours each week by stopping manual sorting.
✓ Reduce errors in customer targeting by filtering automatically.
✓ Handle multiple routing paths inside a clear, easy workflow.
✓ Visual notes make understanding and maintenance simpler.
→ Customer messages better match their region and interests.
→ Users with little coding skill can change filters and routes easily.


Frequently Asked Questions

Yes, any n8n node outputting similar JSON customer data can replace the Customer Datastore node.
For hundreds to a few thousand customers, performance impact is small. For larger data, consider batching or external processing.
Data stays inside the n8n instance. Use secure authentication and restrict access to keep data safe.
Activate the workflow and add a Cron node to schedule regular execution. Monitor logs to check for errors.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free