Skip to main content

Classify Document using n8n action

PDF4me Classify Document automatically analyzes and categorizes PDF documents using AI-powered machine learning through n8n automation workflows. Process PDFs via n8n triggers, binary data, base64 strings, or public URLs to identify document types (invoices, contracts, receipts, forms, reports), extract classification metadata, confidence scores, alternative classifications, and structured JSON output for intelligent document routing. This solution is ideal for automated document sorting, content management systems, compliance workflows, mailroom automation, invoice processing, and intelligent document routing that require accurate AI-powered classification with real-time analysis and seamless integration.

Setup

Add the PDF4me "Classify Document" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.

Prerequisites:

  • PDF4me API credentials
  • n8n workflow access

Configuration:

  1. Add PDF4me node to workflow
  2. Select "Classify Document" action
  3. Configure input parameters (see below)
Classify Document

Parameters

Complete list of parameters for the Classify Document action. Configure these parameters to control document classification.

Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.

ParameterTypeDescriptionExample
Input Data Type***StringPDF Input Format Selection
• Choose the format of your PDF data input
• PDF4me supports multiple input types
• Options: Binary Data, Base64 String, or URL
Binary Data
Input Binary FieldBinaryBinary PDF File Input (Required if Binary Data)
• Reference PDF file from previous n8n node or file upload
• PDF4me processes binary PDF files with automatic format detection
• Required when Input Data Type is "Binary Data"
{{ $binary.data }}
Base64 Document ContentStringBase64 Encoded PDF Input (Required if Base64 String)
• Provide PDF data as base64 encoded string
• PDF4me automatically decodes and processes the PDF content
• Required when Input Data Type is "Base64 String"
UEsDBBQABgAI...
File URLStringPublic PDF URL Input (Required if URL)
• Provide a public/open permission URL to the PDF file
• PDF4me downloads and processes the file from URL
• Required when Input Data Type is "URL"
https://abc.com/sample.pdf
Document Name***StringSource PDF Reference
• Specify the name of the source PDF file
• For reference and tracking purposes in classification
• Helps with processing tracking
invoice_2024.pdf

Advanced Options

The following parameters are available in the Advanced Options section and are optional:

ParameterTypeDescriptionExample
Custom ProfilesStringCustom Configuration Profiles
• Set additional options using custom profiles
• JSON-like format containing predefined parameters
• Enables advanced classification processing settings
• Optional for specialized requirements
{ "OutputDataFormat": "json" }

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringPDF4me output file name - Name of the generated JSON file containing the classification results. The file contains all document classification information in JSON formatclassification_results_1756990750241.json
mimeTypeStringPDF4me file MIME type - MIME type of the output file, always "application/json" for JSON format classification dataapplication/json
fileSizeNumberPDF4me file size in bytes - Size of the generated JSON file in bytes, provided for storage planning and transfer monitoring221
successBooleanPDF4me classification status indicator - Boolean flag indicating the success or failure of the document classification process. PDF4me returns true for successful classifications and false for any errorstrue
messageStringPDF4me classification status message - Human-readable status message providing details about the classification process result. Includes success confirmation or error details for troubleshootingDocument classification completed successfully
docNameStringPDF4me source document reference - Original filename of the PDF document that was processed for classificationdocument.pdf

JSON File Structure

The downloadable JSON file contains document classification data with the following format:

FieldTypeDescriptionExample
classNameStringPDF4me document class identifier - The specific document class or category identified by the AI classification engineinvoice
confidenceNumberPDF4me classification confidence - Confidence score (0-1) indicating the reliability of the classification result0.95
templateIdStringPDF4me template identifier - Unique identifier for the document template used in classification00000000-0000-0000-0000-000000000000
classificationTimestampStringPDF4me classification timestamp - ISO 8601 timestamp indicating when the classification was completed2025-09-23T18:33:43.457Z
alternativeClassificationsArrayPDF4me alternative classifications - Array of alternative document types with their confidence scores[{"type": "receipt", "confidence": 0.15}]

N8N Action Response

The PDF4me Classify Document API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:

JSON Response Format

The raw JSON response from the API:

[
{
"fileName": "classification_results_1756990750241.json",
"mimeType": "application/json",
"fileSize": 221,
"success": true,
"message": "Document classification completed successfully",
"docName": "document.pdf"
}
]

Use Cases

Document Classification and Routing

  • Intelligent Document Routing: Download and process the JSON file to extract the className field for automatically routing documents to appropriate departments, systems, or processing queues based on their identified document type
  • Template-Based Processing: Leverage the templateId from the JSON file to apply specific document templates and processing rules for consistent handling of similar document types
  • Automated Workflow Triggers: Parse the JSON file and trigger specific n8n workflows based on the className value to initiate document-specific business processes

Audit and Compliance Tracking

  • Request Traceability: Use the generated JSON file for complete audit trails and request tracking throughout your document processing pipeline
  • Processing Timestamp Monitoring: Utilize the classificationTimestamp from the JSON file to monitor processing times and ensure SLA compliance
  • Operation Logging: Track all classification operations using the JSON file for comprehensive activity logging and compliance reporting

Document Management and Organization

  • Source File Tracking: Use the docName field to maintain document lineage and track original file names through processing workflows
  • Success Status Monitoring: Implement error handling and retry logic based on the success status for robust document processing
  • File-Based Management: Organize documents by processing the generated JSON files for consistent classification and document standardization

Step-by-step guides to classify and route documents by type:

Get Help