Dynamic Text Classifier

Classify your text into distinct categories

Overview

The Dynamic Text Classifier node classifies input text into predefined categories using a language model. It is designed to help users automatically label or tag textual data based on custom category definitions. This node is useful in scenarios such as:

  • Categorizing customer feedback or support tickets into topics.
  • Tagging social media posts or reviews by sentiment or subject.
  • Organizing documents or messages by themes for further processing.

The node supports multiple classification modes, including single-label and multi-label classification, and can handle cases where the input does not clearly match any category by either discarding the item or routing it to an "Other" output branch.

Practical Example

Suppose you have customer support messages and want to classify them into categories like "Billing", "Technical Issue", and "General Inquiry". You define these categories in the node, provide the message text as input, and the node outputs which category (or categories) each message belongs to, enabling automated routing or analysis.


Properties

Name Meaning
Text to Classify The text string to be classified. Can be static text or dynamically referenced from previous nodes.
Enabled Intents A JSON array of enabled intents with objects containing name, description, and priority. Used to filter and prioritize categories for classification.
Categories A collection of categories to classify the text into. Each category has a name and an optional description. Multiple categories can be added.
Options A collection of additional options:
- Allow Multiple Classes To Be True: Boolean to enable multi-class classification (multiple categories can be true).
- When No Clear Match: What to do if no category fits (discard or other).
- System Prompt Template: Custom prompt template string for the language model.
- Enable Auto-Fixing: Whether to auto-fix broken outputs by triggering an additional language model call.

Output

The node outputs items grouped by category branches corresponding to the defined categories. Each output branch contains items classified into that category.

  • The JSON output for each item is an object with boolean fields named after each category, indicating whether the item belongs to that category (true or false).
  • If the fallback option "other" is selected, an additional output branch named "Other" will contain items that did not match any category.
  • If multi-class classification is disabled, only one category will be marked true.
  • If multi-class classification is enabled, multiple categories may be true for a single item.
  • In case of errors during classification, the error message is included in the item's JSON under an error field.

The node does not output binary data.


Dependencies

  • Requires an AI language model connection configured in n8n (input named "Model").
  • Uses the language model to generate classification results based on prompts constructed from the categories and options.
  • No external API keys or services beyond the connected AI language model are explicitly required.
  • Optionally uses internal utilities for output parsing and fixing.

Troubleshooting

  • Error: "At least one category must be defined"
    Occurs if no categories are provided. Fix by adding at least one category in the node settings.

  • Classification errors or unexpected output format
    May happen if the language model returns malformed JSON. Enabling "Enable Auto-Fixing" can trigger an additional call to fix output formatting.

  • No items appear in output branches
    Check the "When No Clear Match" option. If set to "Discard Item," unmatched items are dropped silently. Consider switching to "Output on Extra, 'Other' Branch" to capture unmatched items.

  • Multiple categories assigned when not expected
    Verify the "Allow Multiple Classes To Be True" option. Disable it to enforce mutually exclusive classification.

  • Performance issues or timeouts
    Large input batches or complex prompts may increase execution time. Consider reducing batch size or simplifying categories.


Links and References

Discussion