Overview
This node classifies input text into one or more predefined categories using a connected AI 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 be used to categorize customer feedback into topics like "Product Quality," "Shipping," or "Customer Service," or to classify support tickets by issue type.
The node sends the input text along with category information to an AI model, which returns a JSON indicating which categories apply. It supports both single-label classification (only one category true) and multi-label classification (multiple categories can be true). It also handles cases where no category matches by either discarding the item or routing it to a special "Other" output branch.
Properties
| Name | Meaning |
|---|---|
| Text to Classify v1 | The text string to classify. Can be static text or an expression referencing previous node data. |
| Categories v1 | A list of categories to classify the text into. Each category has: • Category: The category name (string). • Description: Optional description to clarify the category's meaning. |
| Options v1 | Collection of options: • Allow Multiple Classes To Be True: Boolean flag to allow multiple categories to be true simultaneously (multi-label classification). • When No Clear Match: What to do if none of the categories match exactly: – Discard Item: Ignore and drop from output. – Output on Extra, 'Other' Branch: Route to a separate "Other" output. • System Prompt Template: Custom prompt template string sent to the AI model, with placeholders for categories and formatting instructions. • Enable Auto-Fixing: Whether to enable automatic fixing of broken AI outputs by triggering an additional call to the AI model. |
Output
The node outputs one or more branches corresponding to the categories defined plus optionally an "Other" branch if fallback is set to output unmatched items separately.
- Each output branch contains items 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 per item.
- If fallback is enabled as "other," items not matching any category appear in the "Other" output branch.
- If fallback is "discard," unmatched items are dropped from all outputs.
- If an error occurs during classification and "Continue On Fail" is enabled, the error message is included in the JSON output of the first output branch.
No binary data output is produced by this node.
Dependencies
- Requires connection to an AI language model node as input, which provides the language model used for classification.
- Uses LangChain libraries internally for prompt templating, message handling, and output parsing.
- No external API keys or credentials are managed directly by this node; authentication depends on the connected AI language model node.
Troubleshooting
Error: "At least one category must be defined"
This error occurs if no categories are provided. Ensure you add at least one category under "Categories v1."Classification errors or unexpected output format
If the AI model returns output that cannot be parsed, enabling "Enable Auto-Fixing" may help by triggering a retry with output correction.Items missing from output
Check the "When No Clear Match" option. If set to "Discard Item," unmatched items will not appear in any output branch.Multiple categories true when not expected
Verify the "Allow Multiple Classes To Be True" option. If false, only one category should be true per item.Errors during AI invocation
If the node fails due to AI model errors and "Continue On Fail" is off, the workflow will stop. Enable "Continue On Fail" to capture errors per item instead.