Function Types
Route Functions
Direct data to different processing paths based on content
Route functions classify incoming data and direct it to different processing paths. They use AI to analyze content and determine which downstream function should handle it.
When to Use
Use a Route function when you need to:
- Classify documents by type (e.g. discerning between invoices, receipts, and contracts)
- Direct different document types to specialized transform or analyze functions
- Build branching workflows
- Handle mixed document batches
Configuration Fields
Required Fields
| Field | Type | Description |
|---|---|---|
functionName | string | Unique identifier for the function |
type | string | Must be "route" |
description | string | Description of the routing logic and expected inputs |
routes | array | Array of route definitions |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
displayName | string | - | Human-readable display name |
tags | string[] | - | Tags for organization |
Route Configuration
Each route in the routes array has these fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for this route |
description | string | No | Description of when to use this route |
functionName | string | Conditional | Target function name |
isErrorFallback | boolean | No | If true, handles unclassified documents |
Example
{
"functionName": "document-router",
"type": "route",
"displayName": "Document Classification Router",
"description": "Classifies incoming documents and routes them to the appropriate extraction function. Handles invoices, receipts, purchase orders, and contracts.",
"routes": [
{
"name": "invoices",
"description": "Route for invoice documents including bills and payment requests",
"functionName": "invoice-extractor"
},
{
"name": "receipts",
"description": "Route for receipts from purchases and transactions",
"functionName": "receipt-extractor"
},
{
"name": "purchase-orders",
"description": "Route for purchase order documents",
"functionName": "po-extractor"
},
{
"name": "contracts",
"description": "Route for 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 is critical for accurate routing. Include:
- Clear criteria - What makes a document belong to this route?
- Examples - Specific document types or characteristics
- Distinguishing features - How to differentiate from similar routes
Good Description Example
{
"name": "invoices",
"description": "Route for 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 route with isErrorFallback: true to handle documents that don't match other categories. This prevents unclassified documents from failing.
Email Integration
Route functions receive an email address. When documents are sent to this address, they're automatically classified and routed to the appropriate downstream function.