How to Automate Invoice Processing with OpenClaw in Paradime

Feb 26, 2026

Table of Contents

Automate Invoice Processing with Paradime, OpenClaw, and the Gmail API

Stop chasing invoices across inboxes. This guide walks you through building an automated invoice-processing pipeline that scans your Gmail for invoices, extracts key fields (vendor, amount, due date, PO number) using the OpenClaw SDK, and appends them to a Google Sheets tracking spreadsheet — all orchestrated on a daily cron schedule via Paradime Bolt.

The guide follows an incident-friendly mindset: structured steps, a decision tree for common failures, and a "time to first clue" approach to debugging. Every section is designed for reproducibility and minimal fixes so you spend less time troubleshooting and more time shipping.

What Is Paradime?

Paradime is the all-in-one, AI-native platform that replaces dbt Cloud™. It lets fast-moving data teams code, ship, fix, and scale data pipelines for analytics and AI — all in one place. Its key components include:

Component

What It Does

Code IDE

AI-native IDE with DinoAI built-in. Cuts dbt™ and Python development time by 83%+.

Bolt

Production scheduler for dbt™ orchestration. Supports cron, on-merge, API, and on-completion triggers. Slashes error resolution time by 70%.

Radar (FinOps)

Cost optimization for Snowflake and BigQuery.

Integrations

Slack, Jira, Linear, Looker, Tableau, and dozens more.

For this tutorial, Bolt is the hero — it will run our Python invoice-processing script on a daily cron schedule and give us DinoAI-powered debugging when something goes wrong.

Why Paradime for invoice processing? Bolt natively supports Python scripts with Poetry dependency management, secure environment variables for API keys, and AI-generated Summary Logs that tell you exactly what failed and how to fix it — all with SOC 2 Type II compliance.

What Is OpenClaw?

OpenClaw is an AI platform for building AI agents and assistants. It can run on your own devices and connects to popular messaging platforms while preserving full data privacy (all agent data can be stored locally in a SQLite database). Key capabilities include:

  • Multi-channel AI assistants across 12+ messaging platforms

  • Vision inputs for image understanding (including scanned PDFs)

  • Browser automation via a managed Chrome instance

  • Skills system for composable, pluggable capabilities (OCR, document parsing, field extraction)

  • Structured data extraction from PDFs, images, and text using a parse-then-extract approach

The openclaw-sdk Python package (available on PyPI — latest version 2.1.0) provides a programmatic interface to OpenClaw's extraction and agent capabilities directly from Python scripts.

Architecture Overview

Before we dive into code, here is the end-to-end flow:

Figure 1: End-to-end invoice processing pipeline — from Bolt trigger to Google Sheets output.

Setup: openclaw-sdk + Gmail API + Google Sheets API

Step 1 — Google Cloud Project & API Credentials

  1. Go to the Google Cloud Console.

  2. Create a new project (e.g., invoice-processor).

  3. Navigate to APIs & Services → Library.

  4. Enable both Gmail API and Google Sheets API.

  5. Navigate to APIs & Services → Credentials.

  6. Create a Service Account (for server-to-server auth — no browser needed).

  7. Download the JSON key file — this becomes your GOOGLE_CREDENTIALS_JSON.

  8. Share your target Google Sheet with the service account email (e.g., invoice-bot@your-project.iam.gserviceaccount.com) as an Editor.

⚠️ Security note: Never commit the JSON key file to Git. Store it as an environment variable in Paradime Bolt.

Step 2 — OpenClaw API Key

  1. Sign up at openclaw.ai.

  2. Navigate to your account settings and generate an API key.

  3. Copy the key — this becomes your OPENCLAW_API_KEY.

Step 3 — Project Dependencies

Create a pyproject.toml in the root of your dbt™ project for Poetry dependency management (required by Paradime Bolt):

Step 4 — Environment Variables in Paradime Bolt

  1. In Paradime, click Settings → Workspaces → Environment Variables.

  2. In the Bolt Schedules section, click Add New.

  3. Add the following variables:

Key

Value

Description

GOOGLE_CREDENTIALS_JSON

{"type": "service_account", ...}

Full JSON contents of your service account key

OPENCLAW_API_KEY

sk-...

Your OpenClaw API key

INVOICE_SHEET_ID

1aBcDeFg...

The Google Sheet ID from the URL

GMAIL_USER_EMAIL

invoices@yourco.com

The Gmail account to scan

📖 Docs: Bolt Schedule Environment Variables

Script: Scan Inbox, Extract Fields, Append to Spreadsheet

Here is the full Python script. Save it as scripts/process_invoices.py in your dbt™ project:

Decision Tree: What Happens When Extraction Fails?

Figure 2: Decision tree for extraction and validation — prioritizing reproducibility and minimal fixes.

Bolt Schedule: Cron Daily

Option A — Schedules as Code (YAML)

Add the following to your paradime_schedules.yml in the project root:

Option B — Via the Bolt UI

  1. Navigate to Bolt in Paradime → click New Schedule.

  2. Set Schedule Type to Standard.

  3. Set Branch to main.

  4. Under Commands, add:

  5. Under Trigger Type, select Scheduled Run and enter: 0 6 * * *.

  6. Set Timezone to UTC (or your preferred timezone).

  7. Click Deploy.

📖 Docs: Creating Bolt Schedules | Trigger Types | Python Scripts in Bolt

⚠️ Important: The first command in a Bolt schedule that uses Python must be poetry install to install dependencies and create the virtual environment.

Monitoring and Debugging

Time to First Clue: A 3-Layer Logging Strategy

Paradime Bolt provides three log levels for every run, designed to get you from "something broke" to "here's the fix" as fast as possible:

Figure 3: "Time to first clue" debugging workflow — start broad, zoom in only if needed.

Log Level

What It Shows

When to Use

Summary Logs

DinoAI-generated overview: which commands passed/failed, error descriptions, and suggested fixes

First stop. 80% of issues are diagnosed here.

Console Logs

Chronological record of all operations — our logger.info() output lives here

When you need the exact error message or stack trace.

Debug Logs

System-level operations and dbt™ internals

Deep performance tuning or environment-level issues.

Accessing Logs

  1. Go to Bolt → click your schedule name → Run History.

  2. Click the failed run (status shows Error).

  3. Scroll to Logs and Artifacts.

  4. Click the failed command (e.g., python scripts/process_invoices.py).

  5. Start with Summary Logs — DinoAI will tell you what went wrong.

Setting Up Notifications

Don't wait for someone to check the UI. Configure Slack and email alerts:

  • In YAML: Add notifications block (shown in the schedule YAML above).

  • In UI: Edit schedule → Notifications section → add Slack channels and email addresses.

📖 Docs: Viewing Run History & Analytics | Debugging Failed Runs | Setting Up Notifications

Troubleshooting Common Issues

Issue 1: ModuleNotFoundError: No module named 'openclaw_sdk'

Field

Detail

Symptom

Script crashes immediately on import.

Root Cause

poetry install didn't run, or openclaw-sdk is missing from pyproject.toml.

Fix

Ensure poetry install is the first command in your Bolt schedule. Verify openclaw-sdk is listed in [tool.poetry.dependencies].

Time to First Clue

Summary Logs → "ModuleNotFoundError" in the DinoAI summary.

Issue 2: 403 Forbidden from Gmail API

Field

Detail

Symptom

HttpError 403: Insufficient Permission when calling users().messages().list().

Root Cause

Service account doesn't have domain-wide delegation enabled, or the Gmail API scope is missing.

Fix

1) Enable domain-wide delegation in Google Cloud Console. 2) In the Google Admin Console, authorize the service account client ID for the gmail.readonly scope. 3) Ensure subject= is set in the credentials to impersonate the mailbox owner.

Time to First Clue

Console Logs → look for the HTTP 403 response body.

Issue 3: OpenClaw extraction returns empty fields

Field

Detail

Symptom

All fields come back as empty strings. Row is skipped due to validation.

Root Cause

Attachment is a scanned image PDF without OCR, or the file is corrupted/password-protected.

Fix

1) Verify the attachment downloads correctly (check file size > 0). 2) Ensure your OpenClaw plan supports OCR/vision for scanned documents. 3) Add a pre-processing step with pdfplumber or PyMuPDF to verify the PDF contains extractable text.

Time to First Clue

Console Logs → look for Validation errors: ['Missing vendor name', 'Missing amount'].

Issue 4: gspread.exceptions.SpreadsheetNotFound

Field

Detail

Symptom

Script fails at the append_to_sheet step.

Root Cause

The INVOICE_SHEET_ID env var is wrong, or the service account email hasn't been shared on the Sheet.

Fix

1) Double-check the Sheet ID (from the URL: docs.google.com/spreadsheets/d/{SHEET_ID}/edit). 2) Share the Sheet with the service account email as Editor.

Time to First Clue

Summary Logs → DinoAI will flag the gspread error and suggest checking permissions.

Issue 5: OPENCLAW_API_KEY not set or invalid

Field

Detail

Symptom

openclaw_sdk.AuthenticationError or 401 Unauthorized.

Root Cause

Environment variable is missing or the API key has expired / lacks the required scope.

Fix

1) In Paradime Settings → Environment Variables → Bolt Schedules, verify the key exists and the value starts with sk-. 2) Regenerate the key from your OpenClaw dashboard if expired. 3) Ensure the key has documents:read scope.

Time to First Clue

Summary Logs → "AuthenticationError" in the overview.

Issue 6: Duplicate rows in Google Sheets

Field

Detail

Symptom

Same invoice appears multiple times in the spreadsheet.

Root Cause

The script re-processes emails that were already handled in a previous run.

Fix

Add a deduplication check before appending. Query the existing sheet for invoice_number + vendor + amount. If the combination exists, skip. Alternatively, apply a Gmail label (e.g., processed-by-bot) after processing and exclude labeled messages from the query.

Time to First Clue

Visual inspection of the Sheet, or add a logger.info() that logs the dedup check result.

Quick Diagnostic Checklist

Figure 4: Diagnostic checklist — follow the arrows to resolve the most common failure modes.

Wrapping Up

You now have a fully automated invoice processing pipeline that:

  1. Scans your Gmail inbox daily for new invoices using the Gmail API.

  2. Extracts vendor, amount, due date, PO number, and other key fields using the OpenClaw SDK.

  3. Validates extracted data with mandatory field checks and deduplication logic.

  4. Appends clean, structured rows to a Google Sheets tracking spreadsheet.

  5. Runs on autopilot via a Paradime Bolt cron schedule with poetry install + Python script execution.

  6. Alerts you via Slack and email when something goes wrong — with DinoAI-powered Summary Logs that pinpoint the root cause.

What to Do Next

  • Add deduplication: Implement Gmail label-based tracking or Sheet-level dedup (see Issue 6 above).

  • Expand extraction fields: Add line_items, tax, subtotal, and payment_terms to your EXTRACTION_SCHEMA.

  • Build a dbt™ model on top: Point dbt™ at the Google Sheet (via a Sheets connector or export to your warehouse) and build models for AP aging, vendor spend analysis, and cash flow forecasting.

  • Set up SLA monitoring: The sla_minutes: 30 config in the YAML schedule will alert you if the pipeline takes too long — a signal that Gmail volume spiked or OpenClaw is throttling.

Key Resources

Resource

Link

Paradime Documentation

docs.paradime.io

Bolt Schedules

Creating Schedules

Bolt Python Scripts

Python Scripts in Bolt

Bolt Environment Variables

Bolt Schedule Env Vars

Bolt Debugging

Debugging Failed Runs

OpenClaw Documentation

docs.openclaw.ai

OpenClaw SDK (PyPI)

openclaw-sdk

Gmail API Quickstart

Google Gmail API

Google Sheets API Quickstart

Google Sheets API Python

Cron Expression Help

crontab.guru

Built with Paradime Bolt and OpenClaw — because your finance team deserves better than "can you forward that invoice again?"

Interested to Learn More?
Try Out the Free 14-Days Trial

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.