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.

Related Blog Posts(1)

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.

ParameterRequiredWhat it doesExample
Input Data TypeRequiredChoose how to provide the PDF file to classify. Options: Binary Data, Base64 String, URL. Default is `Binary Data`.Binary Data
Input Binary FieldConditionalName of the binary property that contains the PDF file (usually "data" for file uploads). Shown when Input Data Type is Binary Data. Default is `data`.data
Base64 PDF ContentConditionalBase64 encoded PDF document content. Shown when Input Data Type is Base64 String.UEsDBBQABgAI...
PDF URLConditionalURL to the PDF file to classify. Shown when Input Data Type is URL.
Document NameOptionalName of the document (used for processing). Default is `document.pdf`.document.pdf
Output Binary Field NameOptionalNot used: this operation returns no file, only the classification result as JSON. Default is `data`.data
Advanced OptionsOptionalOptional settings, collapsed behind Add Option.Add Option
Custom ProfilesOptionalUse 'JSON' to adjust custom properties. Review Profiles at https://dev.pdf4me.com/apiv2/documentation/ to set extra options for API calls and may be specific to certain APIs.{ "OutputDataFormat": "json" }

Output​

Output Parameters​

FieldTypeWhat it contains
_metadataStringObject added by the node: success (always true), message (`Document classified successfully`), processingTimestamp (time the node received the result, ISO 8601), sourceFileName (the input file's name for Binary Data, the last part of the URL for URL, and Document Name for Base64) and operation (`classifyDocument`).

All fields of the PDF4me response are copied into the item: the classification result, such as the class name of the document (className in the Power Automate connector). The exact fields depend on the PDF4me response.

All fields of PDF4me's response are copied into the item: the classification result, such as the class name of the document (className in the Power Automate connector). The exact fields depend on PDF4me's response.

JSON File Structure​

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

FieldTypeWhat it contains
_metadataStringObject added by the node: success (always true), message (`Document classified successfully`), processingTimestamp (time the node received the result, ISO 8601), sourceFileName (the input file's name for Binary Data, the last part of the URL for URL, and Document Name for Base64) and operation (`classifyDocument`).

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

Get Help​