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
Automate customer data routing with n8n and If nodes

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

Learn how to Build this Workflow with AI:

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.


Automate customer data routing with n8n and If nodes

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.