Skip to content

Automatically extract structured invoice data with Zapier and the ParserData API, converting PDF invoices into clean JSON for automation, spreadsheets, and accounting workflows.

License

Notifications You must be signed in to change notification settings

parserdata/parserdata-zapier-invoice-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ParserData + Zapier: Invoice data extraction

Automatically extract structured invoice data using Zapier and the ParserData API, then send clean JSON to your favorite apps.

Zapier ParserData

What this example does

This Zapier integration template enables you to create automated workflows that:

  • Trigger on new invoices (from email, cloud storage, forms, etc.)
  • Send the invoice to ParserData API for intelligent data extraction
  • Receive structured JSON with extracted invoice fields
  • Connect the clean data to accounting software, CRMs, databases, or spreadsheets

Popular use cases

1. Gmail → ParserData → QuickBooks/Zero

  • Trigger: New email with invoice attachment in Gmail
  • Action: Extract invoice data using ParserData
  • Action: Create expense/transaction in QuickBooks or Zero

2. Dropbox/Google Drive → ParserData → Airtable

  • Trigger: New invoice file uploaded to cloud storage
  • Action: Extract structured data using ParserData
  • Action: Add record to Airtable database

3. Form Submission → ParserData → Slack/Email

  • Trigger: Invoice uploaded via form (JotForm, Typeform)
  • Action: Extract and validate invoice data
  • Action: Send notification with extracted fields to team

Requirements

  • A Zapier account (Free or Paid)
  • A ParserData API key (Sign up here)
  • Source of invoices (Gmail, Dropbox, Google Drive, etc.)
  • Destination app (QuickBooks, Airtable, Google Sheets, etc.)

Step-by-step setup

Step 1: Create your zap

  1. Log into Zapier.com
  2. Click "Create Zap"
  3. Give your Zap a name: "Invoice processing with ParserData"

Step 2: Set up trigger

Choose your trigger app:

  • Gmail: "New Email" trigger with filters for invoice emails
  • Google Drive: "New File in Folder" trigger
  • Dropbox: "New File" trigger
  • Typeform/JotForm: "New Submission" trigger

Configure the trigger according to your needs.

Step 3: Add ParserData extraction

Add a "Code by Zapier" step:

  1. Click "+" to add a step
  2. Search for "Code by Zapier"
  3. Choose "Run JavaScript"

JavaScript Code:

const axios = require('axios');

// Get API key from Zapier secrets (see Security section)
const apiKey = process.env.PARSERDATA_API_KEY;

// Get file from previous step
const fileUrl = inputData.fileUrl; // From trigger
const fileContent = inputData.fileContent; // Base64 encoded file

async function extractInvoiceData() {
  try {
    // Prepare form data
    const formData = new FormData();
    formData.append('prompt', 'Extract invoice number, invoice date, supplier name, total amount, tax amount, line items (description, quantity, unit price, net amount), and payment terms.');
    formData.append('options', JSON.stringify({
      return_schema: false,
      return_selected_fields: false
    }));
    
    // Add file - either from URL or base64
    if (fileContent) {
      const buffer = Buffer.from(fileContent, 'base64');
      formData.append('file', buffer, 'invoice.pdf');
    } else if (fileUrl) {
      // Fetch file from URL
      const response = await axios.get(fileUrl, { responseType: 'arraybuffer' });
      formData.append('file', Buffer.from(response.data), 'invoice.pdf');
    } else {
      throw new Error('No file content or URL provided');
    }

    // Call ParserData API
    const apiResponse = await axios.post('https://api.parserdata.com/v1/extract', formData, {
      headers: {
        'X-API-Key': apiKey,
        ...formData.getHeaders()
      },
      timeout: 300000 // 5 minutes
    });

    // Return cleaned data
    return {
      extractedData: apiResponse.data.result || apiResponse.data,
      fileName: apiResponse.data.file_name || 'invoice.pdf',
      success: true,
      processedAt: new Date().toISOString()
    };
  } catch (error) {
    // Implement retry logic
    if (error.response && [429, 500, 502, 503, 504].includes(error.response.status)) {
      // Log retry attempt
      console.log(`Retry needed for status ${error.response.status}`);
      throw error; // Zapier will retry based on settings
    }
    
    return {
      success: false,
      error: error.message,
      errorDetails: error.response?.data || null,
      processedAt: new Date().toISOString()
    };
  }
}

// Execute and return result
return extractInvoiceData();

Step 4: Configure Input Data

Map the following fields in Code by Zapier:

Field Value
fileUrl URL of invoice file from trigger (if available)
fileContent Base64 encoded file content (if available)
(Optional) customPrompt Custom extraction prompt if different from default

Step 5: Add destination action

Add your destination app:

  • QuickBooks: "Create Expense" or "Create Bill"
  • Airtable: "Create Record"
  • Google Sheets: "Create Spreadsheet Row"
  • Slack: "Send Channel Message"
  • Email: "Send Outbound Email"

Map the extracted fields from ParserData to your destination app fields.

Step 6: Test and turn on

  1. Click "Test" to run a test with a sample invoice
  2. Verify the extracted data looks correct
  3. Turn on your Zap

Security: Storing API key

Never hardcode your API key! Use Zapier's built-in secrets:

  1. In your Zap, go to the Code step
  2. Click "Manage Secrets" (bottom of code editor)
  3. Add a secret named PARSERDATA_API_KEY with your actual API key
  4. Reference it as process.env.PARSERDATA_API_KEY in your code

Error Handling & Retry logic

The example includes:

  1. HTTP Status Code Checking: Automatic retry for 429 (rate limit) and 5xx (server) errors
  2. Zapier Built-in Retry: Configure Zapier to retry failed steps (Settings → Retry)
  3. Timeout Handling: 5-minute timeout for large documents
  4. Structured Error Responses: Clear error messages for debugging

To configure additional retries in Zapier:

  1. Go to Zap Settings
  2. Enable "Retry on failure"
  3. Set maximum retries (recommended: 3)
  4. Set delay between retries (recommended: 5 minutes)

Customizing Extraction

To extract different fields or handle specific document types:

  1. Modify the prompt in the JavaScript code:

    formData.append('prompt', 'Extract purchase order number, supplier, order date, delivery address, line items (product code, description, quantity, unit price, total).');
  2. Handle different file types:

    const fileName = inputData.fileName || 'document';
    const extension = fileName.split('.').pop().toLowerCase();
    // Handle PDF, JPG, PNG, etc.
  3. Add field validation:

    // Validate extracted data
    if (!extractedData.invoiceNumber || !extractedData.totalAmount) {
      return { success: false, error: 'Required fields missing' };
    }

Performance cnsiderations

  1. File Size Limits: ParserData API has file size limits (check latest documentation)
  2. Rate Limits: Be aware of ParserData API rate limits
  3. Concurrent Zaps: Monitor performance if running multiple invoice processing Zaps simultaneously
  4. Processing Time: Allow 5-30 seconds for API response depending on document complexity

Testing your integration

  1. Test with Sample Files: Use provided sample invoices in /samples folder
  2. Monitor Zap History: Check Zapier dashboard for successful/failed runs
  3. Validate Data Quality: Spot-check extracted data against original documents
  4. Load Test: Process multiple invoices to ensure stability

Troubleshooting

Common Issues

Issue Solution
API Key Invalid Verify API key in Zapier secrets, regenerate if needed
File Not Processed Check file format (PDF, JPG, PNG supported), verify file size limits
Timeout Errors Increase timeout in code, check network connectivity
Incorrect Data Extraction Refine extraction prompt, provide clearer examples in prompt
Rate Limit Errors Reduce Zap frequency, implement exponential backoff

Debugging tips

  1. Use console.log() in Code by Zapier to debug intermediate values
  2. Check Zapier task history for detailed error logs
  3. Test API directly with curl: curl -X POST -H "X-API-Key: YOUR_KEY" -F "file=@invoice.pdf" -F "prompt=Extract invoice fields" https://api.parserdata.com/v1/extract
  4. Verify file URLs are accessible (not behind authentication)

Advanced Examples

See /examples directory for:

  • Multi-step extraction workflows
  • Data validation and transformation
  • Error notification setups
  • Batch processing implementations

Need Help?

This repository is a reference example. For production support or custom integration needs, contact support@parserdata.com.

License

MIT

About

Automatically extract structured invoice data with Zapier and the ParserData API, converting PDF invoices into clean JSON for automation, spreadsheets, and accounting workflows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published