Blog

Automating Document Workflows with Smole API

Learn how to build automated document processing pipelines that scale with your business.

Smole Team
  • automation
  • api
  • workflow

Manual document processing doesn't scale. As your business grows, the volume of invoices, receipts, contracts, and forms grows with it. Here's how to build automated workflows that handle documents efficiently.

The Automation Opportunity#

Consider a typical accounts payable workflow:

  1. Receive invoice via email
  2. Manually enter data into accounting system
  3. Match against purchase orders
  4. Route for approval
  5. Process payment

Steps 2-4 can take 15-30 minutes per invoice. With automation, they take seconds.

Building Your First Workflow#

Step 1: Document Ingestion#

Set up automatic ingestion from your document sources:

  • Email attachments
  • Cloud storage (Google Drive, Dropbox, S3)
  • Scanned documents
  • Web uploads

Step 2: Extraction Pipeline#

Send documents to Smole's API for extraction:

JavaScript
const response = await fetch('https://api.smole.ai/v1/extract', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    document: documentBase64,
    schema: invoiceSchema
  })
});
 
const extractedData = await response.json();

Step 3: Data Validation#

Validate extracted data before processing:

JavaScript
function validateInvoice(data) {
  const errors = [];
 
  if (!data.invoice_number) {
    errors.push('Missing invoice number');
  }
 
  if (!data.total_amount || data.total_amount <= 0) {
    errors.push('Invalid total amount');
  }
 
  // Check line items sum
  const lineItemsTotal = data.line_items
    .reduce((sum, item) => sum + item.total, 0);
 
  if (Math.abs(lineItemsTotal - data.subtotal) > 0.01) {
    errors.push('Line items do not match subtotal');
  }
 
  return errors;
}

Step 4: System Integration#

Push validated data to your systems:

  • Accounting software (QuickBooks, Xero, NetSuite)
  • ERP systems (SAP, Oracle)
  • Custom databases
  • Spreadsheets

Workflow Patterns#

Pattern 1: Straight-Through Processing#

For trusted vendors with consistent invoices:

Text
Document → Extract → Validate → Process → Archive

No human intervention required for valid documents.

Pattern 2: Human-in-the-Loop#

For documents requiring review:

Text
Document → Extract → Validate → Review Queue → Approve/Reject → Process

Humans only see exceptions and edge cases.

Pattern 3: Batch Processing#

For high-volume scenarios:

Text
Collect Documents → Batch Extract → Bulk Validate → Bulk Process → Report

Process hundreds or thousands of documents at once.

Scaling Considerations#

Concurrency#

Smole's API supports concurrent requests. For high volume:

JavaScript
const documents = [...]; // Array of documents
const batchSize = 10;
 
for (let i = 0; i < documents.length; i += batchSize) {
  const batch = documents.slice(i, i + batchSize);
  await Promise.all(batch.map(doc => extractDocument(doc)));
}

Error Handling#

Always handle failures gracefully:

JavaScript
async function extractWithRetry(document, maxRetries = 3) {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      return await extract(document);
    } catch (error) {
      if (attempt === maxRetries) throw error;
      await sleep(1000 * attempt); // Exponential backoff
    }
  }
}

Monitoring#

Track key metrics:

  • Documents processed per hour
  • Extraction success rate
  • Average processing time
  • Error patterns

ROI Calculation#

Typical savings from automation:

MetricManualAutomated
Time per invoice20 min30 sec
Cost per invoice$8$0.50
Error rate3%0.1%
Processing capacity24/day1000+/day

For a company processing 500 invoices/month, automation saves 150+ hours and $3,500+ monthly.

Getting Started#

  1. Identify your highest-volume document type - Start where automation has the biggest impact
  2. Build a schema - Define what data you need
  3. Test in the Playground - Validate your approach
  4. Build a simple pipeline - Start with straight-through processing
  5. Add complexity gradually - Implement validation, routing, and integrations

Ready to automate? Check out our API documentation or explore our document processing plans.

View all posts