Classify Functions
Route inputs down labeled paths based on content classification
Classify functions analyze incoming data and direct it down one of several labeled paths, enabling branching workflows driven by content rather than metadata. The model decides which classification an input belongs to based on the per-classification descriptions you provide.
When to Use
Use a Classify function when you need to:
- Identify document types (invoices, receipts, contracts, etc.) and send each to a specialized Extract function
- Build branching workflows where different content needs different processing
- Handle mixed document batches from a shared inbox or upload channel
- Apply a fallback path for inputs that don't match any known category
Configuration Fields
Required Fields
| Field | Type | Description |
|---|---|---|
functionName | string | Unique identifier for the function |
type | string | Must be "classify" |
description | string | Description of the classification logic and expected inputs |
classifications | array | Array of classification definitions |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
displayName | string | - | Human-readable display name |
tags | string[] | - | Tags for organization |
Classification Configuration
Each entry in the classifications array has these fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for this classification — referenced by destinationName in workflow edges |
description | string | No | Description of when this classification applies |
functionName | string | Conditional | Target function name |
isErrorFallback | boolean | No | If true, handles inputs that don't match other classifications |
Example
{
"functionName": "document-classifier",
"type": "classify",
"displayName": "Document Classifier",
"description": "Classifies incoming documents and routes them to the appropriate extraction function. Handles invoices, receipts, purchase orders, and contracts.",
"classifications": [
{
"name": "invoices",
"description": "Invoice documents including bills and payment requests",
"functionName": "invoice-extractor"
},
{
"name": "receipts",
"description": "Receipts from purchases and transactions",
"functionName": "receipt-extractor"
},
{
"name": "purchase-orders",
"description": "Purchase order documents",
"functionName": "po-extractor"
},
{
"name": "contracts",
"description": "Legal contracts and agreements",
"functionName": "contract-extractor"
},
{
"name": "unknown",
"description": "Fallback for documents that don't match other categories",
"functionName": "generic-extractor",
"isErrorFallback": true
}
],
"tags": ["classification", "workflow"]
}Writing Effective Descriptions
The description field on each classification is what the model uses to decide where an input belongs. Include:
- Clear criteria — What makes an input belong to this classification?
- Examples — Specific document types or characteristics
- Distinguishing features — How to differentiate from similar classifications
Good Description Example
{
"name": "invoices",
"description": "Invoice documents. These typically include: vendor information, invoice number, line items with quantities and prices, payment terms, and a total amount due. Includes bills, payment requests, and statements with amounts owed."
}Weak Description Example
{
"name": "invoices",
"description": "For invoices"
}Error Fallback
Always include a fallback classification with isErrorFallback: true to handle inputs that don't match any other category. This prevents unclassified inputs from failing the workflow.
Wiring Into a Workflow
In a workflow, edges leaving a Classify function use destinationName to match the classifications[].name on this function. See Workflows Explained for the full branching pattern.
Email Integration
Classify functions automatically receive an email address. Forward emails to this address to classify them and fan out to the appropriate downstream function.
The email address is returned in the function response as emailAddress (e.g., eml_xxx@actions.bem.ai).
Related
Triage and Extract Logistics Documents
Cookbook: build a Classify → Extract pipeline for invoices, bills of lading, and packing slips
Create a Function API
API reference for creating functions
Extract Functions
Common destination for Classify edges
Workflows Explained
How destinationName wires Classify outputs to downstream functions