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

FieldTypeDescription
functionNamestringUnique identifier for the function
typestringMust be "route"
descriptionstringDescription of the routing logic and expected inputs
routesarrayArray of route definitions

Optional Fields

FieldTypeDefaultDescription
displayNamestring-Human-readable display name
tagsstring[]-Tags for organization

Route Configuration

Each route in the routes array has these fields:

FieldTypeRequiredDescription
namestringYesUnique name for this route
descriptionstringNoDescription of when to use this route
functionNamestringConditionalTarget function name
isErrorFallbackbooleanNoIf 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:

  1. Clear criteria - What makes a document belong to this route?
  2. Examples - Specific document types or characteristics
  3. 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.

On this page