Overview
This node classifies input text into one or more user-defined categories using a language model. It is useful for scenarios where you want to automatically tag, label, or organize textual data based on its content. For example, it can categorize customer feedback into topics like "Product Quality," "Shipping," or "Customer Service," or classify support tickets by issue type.
The node sends the input text along with a prompt describing the categories to an AI language model, which returns a JSON indicating which categories apply. It supports multi-class classification (multiple categories can be true) or single-class classification (only one category true). It also handles cases where no category matches by either discarding the item or routing it to an "Other" output branch.
Properties
| Name | Meaning |
|---|---|
| Text to Classify | The text string to be classified. Can be static or dynamically referenced from previous nodes. |
| Categories | A list 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 | If enabled, multiple categories can be marked as true for a single input text (multi-class classification). Otherwise, only one category can be true (single-class classification). |
| When No Clear Match | Defines what happens if the text does not clearly match any category: - Discard Item: Ignore and drop the item from output. - Output on Extra, 'Other' Branch: Route unmatched items to a separate "Other" output. |
| System Prompt Template | Custom template string used as the system prompt for the language model. It should include placeholders {categories} and formatting instructions. Defaults to a prompt instructing the model to classify text strictly. |
| Enable Auto-Fixing | Enables automatic fixing of broken or invalid model outputs by triggering an additional call to the language model to correct the output format. |
Output
The node outputs one or more branches corresponding to the defined categories plus optionally an "Other" branch if fallback is set to output unmatched items separately.
- Each output branch contains items whose text was classified as belonging to that category.
- The JSON output for each item is a boolean map indicating which categories are true for that item. For example:
{
"CategoryA": true,
"CategoryB": false,
"fallback": false
}
- If multi-class is disabled, only one category will be true.
- If fallback is enabled and triggered, the "Other" branch will contain those items.
- If auto-fixing is enabled, the node attempts to repair malformed outputs from the language model before processing.
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 parse and classify text based on prompts.
- No external API keys or services beyond the AI model credential are needed.
Troubleshooting
Error: "At least one category must be defined"
This error occurs if no categories are provided. Ensure you add at least one category in the node settings.Malformed or unexpected output from the language model
If the model returns output that cannot be parsed as expected, enabling "Enable Auto-Fixing" may help by triggering a correction call. If issues persist, check the system prompt template for correctness.Items dropped unexpectedly
If many items are discarded, verify the "When No Clear Match" option. Setting it to output unmatched items on the "Other" branch can help identify texts that do not fit any category.Multiple categories true when not expected
Check the "Allow Multiple Classes To Be True" setting. Disable it if you want exclusive classification.