Route Emails by Category

Support Inbox Commander - Challenge 3 of 6
Difficulty
2/10
Tags
SwitchGmailConditional Routing
Requirements
Gmail OAuth credentials configured in n8nCompleted "Classify Email Intent" challenge

The outcome: After this challenge, emails will automatically get labeled in Gmail based on their classification, creating instant visual organization. Your inbox becomes self-sorting.

Why this matters: Labels aren't just organization - they're an audit trail. When you check your inbox, you can immediately see what the AI classified each email as. If something's wrong, you can correct it. This visibility is crucial before you let AI agents respond automatically.

The Text Classifier already outputs to multiple branches. You'll add Gmail labels to each path, creating visual organization while setting up the routing for specialized AI agents.

What you'll learn:

  • Multi-output routing - connecting different actions to classification results
  • Gmail labels - automated inbox organization
  • Audit trails - visibility into what automation decided

Your Task

  1. 1Copy the exercise below
  2. 2Paste into your n8n editor (Ctrl+V)
  3. 3Solve it — use hints if you get stuck
  4. 4Check the solution when done

Add routing and labeling to your email triage workflow:

  1. After each Text Classifier output branch, add a Gmail node to add labels:
    • High Priority → "High Priority" label
    • Customer Support → "Support" label
    • Finance/Billing → "Finance" label
    • Promotions → "Promotions" label
  2. Create these labels in your Gmail account if they don't exist
  3. For each labeled email, prepare it for agent processing (you'll add agents in the next challenge)

Test it: Send yourself emails with different intents and verify they receive the correct labels in Gmail.

Expected result: Emails are labeled in Gmail based on their classification.

Hints

  1. The Text Classifier already has 4 output branches - connect a Gmail node to each
  2. For each Gmail node:
    • Set Operation to "Add Labels"
    • Set Message ID to {{ $json.id }} (the email ID)
    • Select the appropriate label
  3. If labels don't exist, create them in Gmail first (Settings → Labels)
  4. You can use Mode: "List" and select the label, or Mode: "ID" with the label ID
  5. Each branch can continue to more nodes after labeling

Explanation

Text Classifier Multi-Output:

The Text Classifier automatically creates one output branch per category. This is different from the Switch node which requires you to define conditions. With Text Classifier, the AI decides the routing - you just connect nodes to each branch.

Why Add Labels?

Labels serve multiple purposes:

  1. Visual organization in Gmail
  2. Audit trail for what your automation classified
  3. Manual override capability (you can re-label if AI was wrong)
  4. Filtering for agents that might need inbox context

Switch vs Text Classifier:

  • Text Classifier: AI-driven routing based on content analysis
  • Switch: Rule-based routing based on exact values or conditions

You might use Switch after Text Classifier to add additional logic, like checking if a High Priority email is from a VIP list.

Preparing for Agents:

Each route now leads to a labeled email. In the next challenge, you'll add AI agents to handle each category with specialized responses.

Copy the Solution

Paste into n8n with Ctrl+V to compare with your approach.

Login to see the exercise

Create an account to access challenges and track your progress.

Log in to see exercise
Step 3 of 6

Next up

Create Specialized Support Agents

Related Content

Continue your learning journey with these related challenges and guides: