FlowKit

n8n's Text Classifier node: route your data by category with AI

Published 30 July 2026 · 4 min read

Sorting incoming email, filing support tickets, separating happy customer reviews from complaints, routing leads to the right team: a huge share of useful automations starts with the same operation — classifying a text into business categories. For a long time that meant either brittle keyword rules or a hand-rolled LLM call with its own prompt, parsing and error handling. n8n's Text Classifier node packages all of it: you describe your categories in plain language, and it routes each item to the matching branch. The reliability of the approach is well documented: a 2023 study by Gilardi, Alizadeh and Kubli published in PNAS ("ChatGPT outperforms crowd workers for text-annotation tasks", see on Google Scholar) shows that on text annotation tasks — relevance, topic, stance — an LLM beats the accuracy of paid human annotators, at roughly one twentieth of the cost.

What the node actually does

The Text Classifier belongs to n8n's AI node family (the LangChain nodes). It takes a text as input, submits it to a chat model connected as a sub-node, and matches the content against the categories you defined. Each category becomes a physical output of the node: an item classified as "Complaint" exits on the Complaint branch, an item classified as "Sales question" on its own. You then wire whatever you want behind each output — a Slack channel, a CRM, a dedicated sub-workflow.

The difference with an IF or Switch node is fundamental: IF and Switch evaluate exact conditions on structured fields; the Text Classifier evaluates the meaning of free text. The two actually complement each other very well within the same workflow.

Step-by-step setup

  1. Add the Text Classifier node and connect a Chat Model sub-node (OpenAI, Anthropic, Mistral, Gemini or a local model via Ollama).
  2. In Text to Classify, map the field to classify: {{ $json.body }} for an email, {{ $json.message }} for a ticket.
  3. In Categories, add each category with a short name and a precise description. This is where everything is decided: the description is sent to the model, and it must state what belongs to the category and what doesn't.
  4. In the options, choose the When No Clear Match behavior: discard the item, or send it to an extra "Other" branch.

Example categories for triaging inbound email:

technical_support: usage problem, bug, error, can't access a product
  already purchased. NOT pre-sales questions.
sales_question: pricing, quote, demo request, or feature question
  before purchase.
billing: missing invoice, wrong amount, refund, VAT.
other: anything that fits none of the categories above.

Writing category descriptions that work

Classification quality depends almost entirely on the descriptions, not on model horsepower. Three rules from experience:

  • Draw the boundaries: the classic ambiguous case ("your product doesn't work, refund me" — support or billing?) must be settled in the description, not left to the model's judgment.
  • Give one example per category right inside the description: "e.g.: 'I haven't been able to log in since yesterday'". One example is worth ten adjectives.
  • Keep categories mutually exclusive if you're routing: if they overlap, enable multi-label classification instead and accept that an item may exit on two branches.

This rubric work is exactly the same as in our guide to AI support ticket scoring: a fuzzy criterion produces a fuzzy classification, whatever the model.

Handling edge cases in production

Empty or off-topic text. Enable the "Other" output rather than silent discarding: in production, that branch is your radar. If it grows, your categories no longer cover what's actually coming in.

Long texts. A three-line email classifies very well; a forwarded thread of fifty messages, much less so. Truncate or summarize long documents first, then classify the summary — more reliable and cheaper.

API errors. The node inherits n8n's standard retry settings. Back it with an Error Workflow and plan a fallback to a second provider if the triage is business-critical.

Costs. A lightweight model is enough: the task is short and bounded. If volume becomes significant, our guide to tracking AI call costs shows how to measure spend per workflow precisely.

Three proven use cases

  • Inbound email triage: Text Classifier right after an IMAP or Gmail trigger, routing to support / sales / billing. It's the core of our free AI email triage workflow over IMAP, and the first building block of the Inbox AI Pack (€79), which adds prioritization, a daily digest and reply drafts.
  • Content moderation: classify form or chat messages as "legitimate / spam / abusive" before publishing, complementing the techniques in our guide to AI phishing and spam detection.
  • Lead qualification: a first semantic triage layer before the finer-grained inbound lead scoring, separating genuine requests from job applications and cold outreach upfront.

Text Classifier or AI Agent?

If your need is "classify then route", the Text Classifier is simpler, faster and cheaper than an AI Agent node: no tools, no memory, no reasoning loop — one decision per item, with outputs wired right on the canvas. Save the AI Agent for cases where classification is just one step in a broader reasoning task. And if you need to extract structured fields on top of the category (amount, product involved, urgency), combine the Text Classifier with an Information Extractor on the relevant branch.

A well-configured classifier is twenty lines of category descriptions replacing hundreds of filter rules — and it improves simply by rereading what comes out of the "Other" branch.

FAQ

Frequently asked questions

What's the difference between the Text Classifier and an IF or Switch node?

IF and Switch route on exact conditions (equality, contains, regex) over already-structured fields. The Text Classifier routes on the meaning of free text: it understands that an email saying 'I haven't been able to log in since yesterday' is a technical support request even though no predefined keyword appears. In practice you combine both: the Text Classifier categorizes, then IF/Switch nodes refine the routing on precise fields.

Can the Text Classifier assign several categories to the same text?

Yes, the 'Allow Multiple Classes To Be True' option enables multi-label classification: a single item can then exit on several branches at once. That's useful for tagging (an article can be both 'product' and 'announcement'), but keep it off for exclusive routing, otherwise one email can trigger two concurrent processing paths.

What happens to a text that matches no category?

By default the item is simply discarded. The 'When No Clear Match' option can instead send it to a dedicated 'Other' branch, which is almost always preferable in production: you see what the classifier couldn't place, and that branch feeds the improvement of your category descriptions.

Which model should I use to keep costs down?

Classification is a short task: a budget model (gpt-4o-mini, Claude Haiku, or Mistral Small) is enough in the vast majority of cases, at a cost of a fraction of a cent per item. If volume is high, deduplicate before classifying and monitor spend with per-workflow cost tracking.

Bundle FlowKit Complet

€269