Overview
This node classifies input text into user-defined categories using a language model. It is useful for scenarios where you want to automatically tag or label text data based on custom categories, such as sorting customer feedback, categorizing support tickets, or organizing content by topic.
The node sends the input text along with category information to a language model prompt that instructs it to classify the text strictly into one or more of the specified categories. It supports both single-label classification (one category per text) and multi-label classification (multiple categories can apply). If the text does not clearly match any category, the node can either discard the item or route it to an "Other" output branch.
Practical examples:
- Classifying product reviews into sentiment categories like Positive, Neutral, Negative.
- Tagging news articles by topics such as Politics, Sports, Technology.
- Sorting emails into folders like Spam, Important, Promotions.
Properties
| Name | Meaning |
|---|---|
| Text to Classify | The text string to be classified. Can be static text or an expression referencing previous node data. |
| Categories | A collection of categories to classify the text into. Each category has a name and an optional description to clarify its meaning. |
| Allow Multiple Classes To Be True | Boolean option to allow multiple categories to be assigned to the same text (multi-label classification). If false, only one category will be selected (single-label classification). |
| When No Clear Match | Defines what happens if the text does not clearly fit any category: • Discard Item — ignore and drop from output. • Output on Extra, 'Other' Branch — send to a separate "Other" output branch. |
| System Prompt Template | Customizable system prompt template string sent to the language model. It includes placeholders for categories and formatting instructions. Defaults to a prompt asking to classify text strictly into the given categories. |
| Enable Auto-Fixing | Enables automatic fixing of the language model output if it is malformed, which may trigger an additional call to the model to correct the output. |
Output
The node outputs an array of arrays, each corresponding to one output branch representing a category. Each inner array contains items classified into that category.
- The main output branches correspond to the user-defined categories.
- If the fallback option "Output on Extra, 'Other' Branch" is selected, an additional output branch named "Other" is created for items that do not match any category.
- Each output item retains the original input data with an added
pairedItemproperty linking back to the input index. - If classification fails and "Continue On Fail" is enabled, the error message is included in the output JSON for that item.
No binary data output is produced by this node.
Dependencies
- Requires an AI language model connection configured in n8n (e.g., OpenAI or other supported LLM).
- Uses the language model to perform classification via prompt engineering.
- No external API keys are directly referenced; the node relies on the connected AI language model credential.
Troubleshooting
Error: "At least one category must be defined"
This occurs if no categories are provided. Define at least one category to proceed.Malformed output from the language model
If the model returns invalid JSON or unexpected format, enabling "Enable Auto-Fixing" helps by triggering a correction call. Otherwise, the node may throw errors.Empty output or all items discarded
Check the fallback option. If set to discard, items not matching any category will be dropped silently.Multiple categories assigned when not expected
Ensure "Allow Multiple Classes To Be True" is set correctly according to your use case.Errors related to AI model connection
Verify the AI language model node is properly connected and authenticated.