Classify Email Intent

Support Inbox Commander - Challenge 2 of 6
Difficulty
3/10
Tags
Text ClassifierOpenAIAI Agents
Requirements
[LLM API credentials](/guides/how-to-add-openai-api-key-to-n8n-node) (OpenAI, OpenRouter, Gemini, Anthropic, or Azure)Completed "Capture Incoming Emails" challenge

The outcome: After this challenge, AI will automatically read each email and decide what type it is - urgent issue, support request, billing question, or promotional. No more scanning subject lines yourself.

Why this matters: Email triage is tedious, repetitive work. Enterprise help desks use AI classification to route tickets to the right teams. You're building the same capability - the difference between a junior support person and an AI-augmented one.

The Text Classifier node uses AI to categorize text into your predefined categories. You define what "High Priority" or "Support Request" means, and the AI makes the call for each email.

What you'll learn:

  • Text Classifier node - AI-powered content categorization
  • Category definitions - teaching AI what each category means
  • Multi-output nodes - different paths based on classification

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 email classification to your workflow:

  1. Connect a Text Classifier node after your Gmail Trigger
  2. Set the input text to the email body
  3. Define four categories with clear descriptions:
    • High Priority: Urgent issues requiring immediate attention
    • Customer Support: General questions and support requests
    • Finance/Billing: Invoice, payment, and account issues
    • Promotions: Marketing emails and promotional content
  4. Connect an OpenAI Chat Model (GPT-4o-mini works well)

Test it: Send yourself emails with different intents and verify they're classified correctly.

Expected output: Each email gets a classification category added to its data.

Hints

  1. Add a Text Classifier node after Gmail Trigger (or your Edit Fields node from Challenge 1)
  2. Set "Input Text" to the email body: {{ $json.text }} or {{ $json.body }}
  3. Click "Add Category" for each classification type
  4. Write clear descriptions that help the AI understand each category:
    • High Priority: "Emails requiring immediate attention, from key stakeholders, time-sensitive requests, escalated issues. Keywords: urgent, ASAP, deadline, critical"
    • Customer Support: "Questions, support tickets, feedback, general inquiries from customers"
    • Finance/Billing: "Invoices, payments, billing questions, account issues, refunds"
    • Promotions: "Marketing emails, newsletters, promotional offers, sales announcements"
  5. Add an OpenAI Chat Model node and connect it to the Text Classifier's AI input
  6. The Text Classifier outputs to separate branches - one for each category

Explanation

How Text Classifier Works:

The Text Classifier is a specialized AI node that takes text input and routes it to one of your defined categories. Under the hood, it uses a language model (OpenAI in this case) with a structured prompt to make the classification decision.

Category Descriptions Matter:

The AI uses your category descriptions to understand what belongs where. Vague descriptions lead to poor classification. Include:

  • What type of content belongs in this category
  • Keywords that signal this category
  • Examples if helpful

Multi-Output Node:

Unlike most nodes that have a single output, Text Classifier has one output branch per category. Each email exits through the branch matching its classification. This sets you up perfectly for routing in the next challenge.

Why GPT-4o-mini?

For classification tasks, you don't need the most powerful model. GPT-4o-mini is fast, cheap, and accurate enough for text categorization.

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 2 of 6

Next up

Route Emails by Category

Related Content

Continue your learning journey with these related challenges and guides: