Overview
The Dynamic Text Classifier node classifies input text into predefined categories using a language model. It is useful for scenarios where you want to automatically tag or label text data based on its content, such as sorting customer feedback, categorizing support tickets, or organizing documents by topic.
The node sends the input text along with a system prompt describing the categories to a language model, which returns a JSON indicating which categories apply. It supports both single-label classification (one category per text) and multi-label classification (multiple categories can be true). If no category matches clearly, it can either discard the item or route it to an "Other" output branch.
Example use cases:
- Automatically tagging emails or messages by topic.
- Classifying product reviews into sentiment categories.
- Sorting news articles into predefined themes.
Properties
| Name | Meaning |
|---|---|
| Text to Classify | The text string to classify. Can be static or dynamically referenced from previous nodes. |
| Enabled Intents | JSON array of enabled intents/categories to consider during classification. |
| Categories | List of categories to classify into. Each category has a name and optional description. |
| Options | Collection of options controlling classification behavior: |
| - Allow Multiple Classes To Be True | Boolean flag to allow multiple categories to be true simultaneously (multi-class classification). |
| - When No Clear Match | What to do if no category matches clearly: either discard the item or output it on an "Other" branch. |
| - System Prompt Template | Custom string template used as the system prompt sent to the language model. |
| - Enable Auto-Fixing | Whether to enable auto-fixing of broken outputs by triggering an additional language model call. |
Output
The node outputs one or more branches corresponding to the defined categories plus optionally an "Other" branch if configured.
- Each output branch contains items classified into that category.
- Items are assigned based on the boolean flags returned by the language model for each category.
- If multi-class is disabled, only one category will be true per item.
- If fallback is set to "other", items not matching any category appear in the "Other" output branch.
- If fallback is "discard", unmatched items are dropped from all outputs.
- The
jsonfield of each output item contains the original input data; classification results are reflected by the routing of items to output branches. - No binary data output is produced.
Dependencies
- Requires an AI language model connection configured in n8n (e.g., OpenAI or other supported LLM).
- Uses LangChain libraries internally for prompt templating and output parsing.
- No external API keys beyond the language model credential are required.
Troubleshooting
Error: "At least one category must be defined"
This occurs if no categories are provided. Define at least one category in the node settings.Classification output errors or invalid JSON
Enabling "Enable Auto-Fixing" helps fix malformed outputs by retrying the language model call.No items appearing in outputs
Check that the input text is correctly passed and that enabled intents match the categories.Multiple categories true when multi-class is disabled
Ensure the "Allow Multiple Classes To Be True" option is set according to your needs.Unexpected fallback behavior
Verify the "When No Clear Match" option is set properly to either discard or output unmatched items.