n8n

How to Automate Gmail to Sheets Expense Tracking?

Keep your spend records up to date without typing. The flow reads invoice and payment emails from Gmail and writes clean expense rows to Google Sheets. Finance teams and small business owners get fast visibility into daily costs and monthly bills.

Two Gmail triggers watch labeled inbox folders every minute. Emails get parsed in two ways. PDF invoices are opened and read, while payment alerts in HTML are scanned for each spend line. A Switch node routes emails with one charge, many charges, or invoices. The HTML path can split multiple line items using a CSS selector, then a Merge node brings email context back. AI models (Google Gemini and Groq) extract date, amount, service, currency, category, and card into a fixed schema. Parsed results append straight to Google Sheets.

You will need Gmail labels and filters, a Google Sheet with matching columns, and API keys for Google Gemini and Groq. Expect big time savings on reconciliation and more accurate records. Great for card spend alerts, vendor invoices, and receipt emails that show many charges in one message.

What are the key features?

  • Gmail triggers watch labeled folders and poll every minute for new invoices and payments.
  • PDF extraction opens attachments and reads content using the defined binary fields.
  • HTML extraction uses a CSS selector to capture each spend line when multiple charges exist.
  • Switch routing separates emails with many charges, single charges, or invoices.
  • Split Out breaks multi line emails into individual items for clean records.
  • LLM parsing with Google Gemini and Groq converts raw text into a structured expense schema.
  • Merge node adds email context like date and subject back to each spend line.
  • Google Sheets nodes append rows to the selected spreadsheet and tab.

What are the benefits?

  • Reduce manual entry from 5 hours per week to 15 minutes by auto logging emails to Sheets
  • Streamline reconciliation by 70 percent with consistent fields for date, amount, and category
  • Improve data accuracy by up to 90 percent using structured AI parsing and fixed schemas
  • Connect Gmail and Google Sheets so finance data moves without copy paste
  • Handle 10 times more email volume with split items and minute by minute polling

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Gmail, Google Sheets, Google Gemini and Groq. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n canvas, open the Get invoice and Get payment trigger nodes. In the Credential to connect with field, click Create new credential and follow the on screen steps to connect your Gmail account with OAuth2.
  4. In the n8n credentials manager, open each Google Sheets node. Click Create new credential, choose Google Sheets OAuth2, and connect your Google account. Pick the target spreadsheet and the correct sheet tab.
  5. Open the Google Gemini Chat Model node. Click Create new credential and add your API key from the official Google Gemini API page. Save the credential and test the connection.
  6. Open the Groq Chat Model node. Click Create new credential and paste your Groq API key from the Groq console. Save and test the credential.
  7. Update Gmail labels in both Gmail trigger nodes to match your inbox setup. In Gmail, create filters that label invoice emails and payment alerts so the triggers read only the right messages.
  8. Check the HTML node and adjust the CSS selector if your emails use a different class name than .spend-table for each spend line.
  9. Open the Structured Output Parser nodes and confirm the schema fields match your Google Sheet columns. If needed, rename fields and update the column mapping in the Google Sheets nodes.
  10. If your invoices are password protected, confirm the PDF extractor uses the correct password and binary property name. Make sure download attachments is enabled in the Gmail triggers.
  11. Run a test by sending a single payment alert and an invoice email to your labeled inbox. Open Executions in n8n to confirm parsed fields, then check the spreadsheet for new rows.
  12. If rows do not appear, verify label IDs, spreadsheet and sheet selections, and that attachments are present. Review the Switch path to ensure each email type hits the correct branch.
  13. When tests look good, enable the workflow. Adjust poll frequency and label filters as your volume grows.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Google Gemini

Sign up

Free tier: $0 via Gemini API; e.g., Gemini 2.5 Flash-Lite free limits 1,000 requests/day (15 RPM, 250k TPM). Paid from $0.10/1M input tokens and $0.40/1M output tokens.

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

Free tier: $0, API key usable via API (rate‑limited)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.