See llms.txt for all machine-readable content.

Back to Templates

Process Gmail invoices into QuickBooks bills with Gemini, Slack and Sheets

Quick overview

Youtube Video: https://youtu.be/y_iyI6JqCE4

This workflow monitors Gmail for unread emails with PDF, uses Gemini (Decisions API + Gemini chat) to classify and extract invoice data, routes uncertain cases to Slack for approval, creates vendors and bills in QuickBooks, syncs vendor contacts to HighLevel, and logs processed invoice to Sheets.

How it works

  1. Triggers every 5 minutes when an unread Gmail message arrives and downloads its attachments.
  2. Checks for a PDF attachment, extracts text from the PDF, hashes the extracted text, and posts a Slack alert if no readable text is found.
  3. Sends the email context and extracted text to the Google Gemini Decisions API to score whether it is a real invoice and posts a Slack alert if the probability is between 30% and 70%.
  4. For invoices with at least 70% probability, uses Google Gemini to extract structured invoice fields and line items into a defined JSON schema.
  5. Looks up the invoice number and vendor name in a Google Sheets “Audit Log” to detect duplicates and posts a Slack notice if the invoice is already logged.
  6. Retrieves the vendor ID from an n8n Data Table (by vendor email) or creates a new vendor in QuickBooks and saves the mapping back to the Data Table.
  7. If the extraction is risky (low confidence, missing fields, mismatched totals, large amount, new vendor, or bank-account mismatch), sends a Slack approval/rejection link, waits up to 24 hours, and continues only on approval.
  8. On approval (or if no review is needed), upserts the vendor contact in HighLevel, creates a bill in QuickBooks, appends/updates the Google Sheets audit log, and posts a Slack success message (or a Slack failure alert if QuickBooks fails).

Setup

  1. Connect credentials for Gmail OAuth2, Google Gemini (Google PaLM/Generative Language API), Slack, QuickBooks Online OAuth2, HighLevel OAuth2, and a Google Service Account for Google Sheets.
  2. Create and share a Google Sheets spreadsheet containing an “Audit Log” sheet with columns matching the workflow fields (at minimum invoiceNumber and vendorName for matching), then update the spreadsheet ID if needed.
  3. Create an n8n Data Table for vendor mappings with vendor_email and vendor_id columns, and select it in the vendor lookup/save steps.
  4. Choose the Slack channel (for example, #general) for alerts, review requests, and success/failure notifications.
  5. In QuickBooks, ensure the account/vendor references used for bill line items are valid for your company, and adjust any defaults (like due date fallback) to match your AP policy.