Dynamic Text Classifier v4

Clasifica texto en categorías basadas en intents dinámicos

Overview

This node is a Dynamic Text Classifier that categorizes input text into one or more predefined intents (categories) based on their descriptions and priorities. It uses an AI language model to analyze the text and determine which intent(s) it belongs to, optionally allowing multiple classifications per input.

Common scenarios where this node is useful:

  • Automatically tagging customer support tickets with relevant issue categories.
  • Classifying user feedback or survey responses into thematic groups.
  • Routing chatbot inputs to appropriate handlers based on detected intents.
  • Organizing large volumes of unstructured text data by topic or intent.

Practical example:
You provide a list of intents such as "Billing Issue," "Technical Support," and "General Inquiry," each with a description and priority. When you input a customer message like "I can't access my account," the node classifies it under "Technical Support" with confidence, enabling automated routing or response generation.


Properties

Name Meaning
Text to Classify The text string that will be analyzed and classified according to the provided intents.
Intents An array of intent objects used for classification. Each intent should have a name, description, and priority.
Options A collection of optional settings:
- Allow Multiple Classes Boolean flag to allow the text to belong to multiple categories instead of just one.
- System Prompt Template Custom template string for the system prompt sent to the AI model, describing how to classify the text.
- Enable Auto-Fixing Boolean flag to enable automatic correction of the AI model's output format to match expected JSON schema.

Output

The node outputs an array of results corresponding to each intent provided. Each element in the output array corresponds to one intent and contains either:

  • A JSON object with:
    • input_text: The original input text.
    • confidence: Confidence score (always 1 in current implementation).
    • intent_data: The matched intent object including its name, description, and priority.

or, if no match or error occurs:

  • A JSON object with:
    • error: Error message describing what went wrong.
    • input_text: The original input text.

If multiple classes are allowed, multiple intents can be marked true; otherwise, only the highest priority matching intent is returned.

The node does not output binary data.


Dependencies

  • Requires an AI language model connection configured in n8n (e.g., OpenAI or other supported LLM).
  • Uses structured output parsing and prompt templates from LangChain libraries bundled within the node.
  • No external API keys or environment variables are explicitly required beyond the AI model credential.

Troubleshooting

  • No intents received: If the node receives no intents to classify, it throws an error "No se recibieron intents para la clasificación". Ensure that the intents array is properly populated before execution.
  • No valid intents found: If after sorting, no valid intents remain, it throws "No se encontraron intents válidos". Check that intents have correct structure and priority values.
  • Output parsing errors: If the AI model returns output that does not conform to the expected JSON schema, enabling "Enable Auto-Fixing" helps automatically correct minor formatting issues.
  • Multiple classes confusion: If multiple classes are enabled but the AI model returns conflicting results, verify the prompt template and intent definitions for clarity.
  • Model invocation failure: Any errors during AI model invocation are caught and returned as error messages in the output JSON.

Links and References

Discussion