Skip to content

Instantly share code, notes, and snippets.

@jimfaster
Created August 11, 2025 14:00
Show Gist options
  • Select an option

  • Save jimfaster/a3d684554a2ac5d0faaf86bc8da9223e to your computer and use it in GitHub Desktop.

Select an option

Save jimfaster/a3d684554a2ac5d0faaf86bc8da9223e to your computer and use it in GitHub Desktop.
Mind map for YouTube video: How to Build a Bookkeeping Agent (No-Code, n8n)

How to Build a Bookkeeping Agent (No-Code, n8n)

TL;DR This video demonstrates how to build a no-code bookkeeping automation agent using n8n to eliminate manual receipt matching. The system integrates bank transactions via Google Sheets, processes incoming email receipts (images or PDFs) using AI and OCR (Mistral OCR), and intelligently matches them to the correct bank transactions, even with similar charges, prioritizing recent activity. It extracts key invoice data, uploads attachments to Google Drive, and updates a central finance reconciliation sheet. For unmatched receipts, it stores them separately for easy manual reconciliation. This automation aims to save significant time, handling approximately 95% of the work, and is designed for future integration with accounting software like QuickBooks or Xero. The setup is estimated to take just 15 minutes, with a template available for quick deployment.


Information Mind Map

🧠 Building a No-Code Bookkeeping Agent (n8n)

🎯 Core Problem & Solution

  • Problem: Manual receipt matching is time-consuming and inefficient.
  • Solution: Automate the process using n8n to match receipts to bank transactions.
  • Benefits:
    • Eliminates manual matching.
    • Finds correct transactions even with multiple similar charges.
    • Reads receipts from images or PDFs using character recognition.
    • Handles unmatched receipts for easy manual reconciliation.
    • High ROI for time invested (15-minute setup).
    • Automates ~95% of the work.

πŸ“Š System Setup: Google Sheets as Central Hub

  • 1. Raw Transactions from Bank Account
    • Source: Bank account (e.g., Monzo) or third-party integrations.
    • Destination: Google Sheet (e.g., "Live Transaction Sheet").
    • Data Captured: Company name, category, amount, local currency.
    • First Automation: Google Sheet trigger – As soon as a transaction enters the "Live Transaction Sheet", it's appended to the "Central Finance Reconciliation Sheet".
      • Actionable:
        • Make a copy of the provided Google Sheet template.
        • Map bank transaction columns to "Raw Live Sheet" columns.
  • 2. Central Finance Reconciliation Sheet
    • Purpose: Main database for all transactions and receipts.
    • Components:
      • Lookups: To match categories (e.g., 11 Labs -> Software).
      • Raw Live Sheet: Where bank transactions are logged and processed.
      • Receipt/Invoice Columns:
        • Email address of origin.
        • Link to original email.
        • Link to Google Drive file (or Dropbox/Shared Drive).
        • Standardized file name.
        • Extracted text from receipt.
        • Download link for the file.
    • Outcome: Transactions with direct links to receipts, ready for accounting software upload or internal reporting.
  • 3. Unmatched Receipts Tab
    • Purpose: Stores receipts that could not be matched to an existing transaction.
    • Details Captured: Links to email, file, total due, etc.
    • Benefit: Simplifies manual reconciliation for edge cases, ensuring no receipts are lost.

βš™οΈ Automation Workflow (n8n) - Node by Node Breakdown

πŸ“§ Flow 1: Receiving & Initial Processing of Receipts (Email Triggered)

  • Trigger: Google Mail (checks designated accounting mailbox, e.g., accounting@scrapes.ai, every minute).
    • Pulls email details and attachments.
  • AI Check 1: Assess Email Relevance (LLM node)
    • Input: Email subject, email body.
    • Prompt: Acts as an "email processing agent" to identify emails with invoices or billing content.
    • Output: True (process) or False (stop execution to save AI tokens).
    • Filter Node: Passes to next stage if True.
  • Extract Key Info about Invoice (LLM node)
    • Input: Email subject, email body.
    • Prompt: Pulls invoice information only from email text (description, invoice date, payment date, invoice number, etc.).
    • Crucial Rule: "If the email body or subject does not contain this information, leave it blank. do not make up this information."
    • Prioritizes attachments as the "source of truth" over email body.
  • Attachment Handling
    • Code Node: Grabs binary data from the original email for attachment.
    • Check for Existing Attachment:
      • If Exists: Skip upload.
      • If Not Exists:
        • Save Attachment to Invoice File (Google Drive Upload node).
        • Naming Convention: Date_SupplierName_EmailInfo (e.g., 2023-08-15_Slack_invoice_link_to_email).
        • Destination: Invoice Uploads folder in Google Drive.

πŸ“ Flow 2: Attachment Processing & Transaction Matching (Google Drive Triggered)

  • Trigger: Google Drive Trigger (starts when new attachments are received in the Invoice Uploads folder).
    • Actionable:
      • Connect Google Drive account.
      • Ensure URL in trigger points to the correct Invoice Uploads folder.
  • Download Google Drive File
  • Determine File Type: Checks mime type (image vs. PDF).
    • Branch 1: Image (mime type image or contains image)
      • Mistral OCR: Optical Character Recognition.
        • Function: Views receipts visually, extracts text from unstructured data (images).
        • Cost: ~$1 per 1000 pages (cost-effective).
        • Process:
          • HTTP Request (upload binary file to Mistral server to get file URL).
          • HTTP Request (send document URL to Mistral for OCR processing).
          • JSON payload specifies image_url.
    • Branch 2: PDF
      • Mistral OCR: Optical Character Recognition.
        • Function: Extracts text from PDFs (even if they contain images).
        • Process:
          • HTTP Request (upload binary file to Mistral server to get file URL).
          • HTTP Request (send document URL to Mistral for OCR processing).
          • JSON payload specifies document_url.
  • Extract Amount Due (LLM node)
    • Input: Markdown/text received from Mistral OCR.
    • Prompt: "Review the whole bit of text and work out what is the amount due."
    • Amount due is considered the single best identifier for matching.
  • Pull Live Transactions (Google Sheet Read node)
    • Source: "Raw Live Sheet".
    • Sorts transactions by most recent (recency bias for matching).
  • Transaction Matching Loop (LLM node within a loop)
    • Input:
      • Transaction data from each row (can be limited to most recent 10).
      • Invoice markdown (from OCR, constant for each loop).
    • Prompt: "You're a transaction matching agent. Compare the invoice data with the existing transaction records. Return true or false. Here are your inputs. Extract invoice key data and make sure that you are sure that this transaction matches."
    • Output: True (match found) or False (no match).
    • Logic:
      • If True: Update Google Sheet (matches transaction with receipt details).
      • If False: Continue loop to next transaction.
  • Handle Unmatched Receipts
    • If no match found after loop: Upload to Unmatched Receipts tab in Google Sheet.
    • Purpose: Ensures all receipts are stored, even if no bank transaction match is found, for later manual reconciliation.

πŸ§ͺ Demo Use Cases

  • 1. Matching with Multiple Similar Transactions (PDF)
    • Example: Slack invoices (June, July, August).
    • Outcome: System correctly identifies and matches the July invoice based on date and amount, leveraging AI and recency bias.
  • 2. Processing Image Receipts
    • Example: Restaurant meal receipt (image).
    • Outcome: System uses Mistral OCR to extract text from the image and successfully matches it to the corresponding transaction.
  • 3. Handling Unmatched Transactions (PDF)
    • Example: Google Cloud invoice not on transaction list.
    • Outcome: Receipt is processed, but since no match is found, it's stored in the "Unmatched Receipts" tab for manual review.
    • Note: May require manual input for missing data (e.g., invoice date).

πŸš€ Future Extensions & Resources

  • Integration with Accounting Software: QuickBooks, Zero, Free Agent.
    • Will allow direct upload of reconciled documents.
  • Community & Template:
    • Grab the complete template and setup guide from school.com/scrapes (Resource Hub -> Bookkeeping under Operations).
    • Option to build logic yourself for free.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment