Mindket

Spending emails in Gmail logged to a Google Sheet by AI

Newversion 1 · updated

Overview

An n8n workflow that reads spending emails under two Gmail labels, opens their PDFs, and asks Gemini or Groq for the date, service, amount, category and currency. It adds one row for each payment to your Google Sheet.

Spending emails in Gmail logged to a Google Sheet by AI is an n8n workflow in the Finance & accounting category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file and publish it
  • Your own n8n server: the same file and steps
  • Gmail: two labels, with filters that apply them on their own
  • Google Sheets: one tab with eight named columns

Platform

Connects 4 apps

How it works

Trigger

New labelled email

It starts when a new email arrives under one of two Gmail labels, checked every minute. It brings:

  • The sender, subject, date and body
  • Any attached files, of which the first is read as a PDF

Actions

  1. Opens the first attached PDF, with a password if you set one, and joins its text to the email
  2. Sorts the mail by sender into emails with several payments, emails with one payment and invoices
  3. Cuts each several-payment email into one piece per payment
  4. Asks Gemini or Groq for the date, service, details, amount, category and currency
  5. Appends one row for each payment to your Google Sheet

Result

A Google Sheet with one row for each payment, holding its date, service, details, amount, category and currency

Integrations

What you need before you start.

Gmail

Mail source

Watches two labels and downloads the attachments of new mail.

NeedsA Gmail OAuth2 credential

Google Gemini

Language model

Reads the emails with several payments or one payment. The copy asks for gemini-3.8-flash.

NeedsA Google AI API key

Groq

Language model

Reads the invoices. The copy asks for llama-3.3-70b-versatile.

NeedsA Groq API key

Google Sheets

Spreadsheet

Appends one row for each payment.

NeedsA Google Sheets OAuth2 credential and a tab with eight named columns

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
17 steps, starting on a Gmail event
AI
2 steps call an AI model: Extract details and Extract details1
Sign-ins
Signs in to: Google Sheets, Google Gemini, Groq and Gmail
API keys
No API key is left in the file
Step types
Mindket’s checker reads all 9 of its step types

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow turns spending emails into rows in a Google Sheet. Two Gmail triggers watch an invoice label and a payment label, and download each email’s attachments. A PDF is opened with a password if you give one, and its text joins the email’s text. A Switch node sorts the mail by sender into three groups: emails that list several payments, emails about one payment, and invoices. The first group is cut into one piece per payment. Gemini reads the first two groups and Groq reads the invoices, and each returns the date, service, details, amount, category and currency. A Sheets node then appends one row. The file holds twenty-one nodes beside three sticky notes.

Who it suits

Freelancers, households and small teams who get card alerts and invoices by email and want them in one sheet. Skip it if your payments never reach Gmail, or if you do not want mail text sent to Google and Groq.

Who uses it, and how
IndustryWho uses itHow they use itExample
Personal financeHouseholdsTrack card spending without typing it inA parent labels the bank’s alert emails and sees each purchase as a row.
FreelanceSelf-employed workersCollect invoices before tax timeA freelancer labels supplier invoices and gets the date, amount and category of each.
AccountingBookkeepersPre-fill a ledger from a client’s mailA bookkeeper reviews the rows that a client’s labelled receipts produce.
RetailSmall shop ownersLog supplier invoicesA shop owner labels delivery invoices and checks the totals by category.

You need to know n8n and Gmail’s labels: import a file, add four credentials, write sender rules and prepare a sheet.

Where to use it

An n8n that can reach Gmail, Google, Groq and Google Sheets will run it.

  • n8n Cloud: import the file and publish it
  • Your own n8n server: the same file and steps
  • Gmail: two labels, with filters that apply them on their own
  • Google Sheets: one tab with eight named columns

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Most of the setup is the sender rules and the sheet.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own
GmailAn OAuth2 credential and two labels
GeminiA Google AI API key
GroqAn API key
Google SheetsAn OAuth2 credential and a tab called Expenses with eight named columns
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. In Get invoice and Get payment, add your Gmail credential and pick the matching label.
  3. In Switch, replace <YOUR_MULTI_PAYMENT_SENDER> with the address that sends mail listing several payments. In the other two rules, replace <YOUR_SINGLE_PAYMENT_SENDERS> with the senders of one-payment mail, separated by |.
  4. If your PDFs are protected, replace <YOUR_PDF_PASSWORD> in Extract invoice and Extract payment.
  5. Add a Gemini credential in Google Gemini Chat Model1 and a Groq credential in Groq Chat Model.
  6. Add a Google Sheets credential in Send and Send1, and replace <YOUR_SHEET_ID> in both with your sheet’s id.
  7. Publish the workflow. Both triggers check Gmail every minute.

How to use it

Label an email, or let your Gmail filter label it. Within a minute a row appears in your sheet. Check the first rows for the right category and currency before you label more.

What to change for a different result
To changeWhere
Which mail goes whereThe three rules in Switch
The categories and currenciesThe schemas in Structured Output Parser and Structured Output Parser1
How the model reads the mailThe messages in Extract details and Extract details1
The columnsThe mapping in Send and Send1, and row 1 of your tab

Example

A card alert lists three purchases in one email. The multi-payment rule sends it to the model once for each purchase, and one of the results looks like this.

{"date": "2026-11-09 18:42", "service": "Uber Eats", "details": "Dinner delivery", "amount": 18.5, "category": "Food & Beverage", "currency": "USD", "card": "Visa 1234"}

The workflow adds three rows to your sheet, one for each purchase, with the card in the payment column.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. This one reads mail, sorts it, asks a model for the figures and writes a row. Start with one labelled email and check its row.

For experts. Two triggers share one sorting step and two models share one sheet.

Where to look closer
NodeWhat it doesWhat to know
SwitchSorts mail by sender into three outputsThe first rule that matches wins, so the invoice rule catches all other mail
HTMLPicks every .spend-table element from a multi-payment emailIt only works when the sender marks each payment with that class
Extract detailsChain with Gemini and a schema that includes cardIt reads the first two groups
Extract details1Chain with Groq and a schema without cardIt reads the invoices
Send and Send1Append rows to your Expenses tabRow 1 must hold the eight names

Good to know

Mail text goes to two AI providers, so label only mail you are happy to share.

  • Models: Google’s pages no longer list gemini-1.5-flash, so this copy asks for gemini-3.8-flash. Groq retired llama-3.2-11b-text-preview, so it asks for llama-3.3-70b-versatile
  • Privacy: the text of each email and of its PDF goes to Google and to Groq
  • Cost: each email is one model call, and a multi-payment email is one call for each payment
  • Sender rules: until you fill them in, all mail takes the invoice path and the Groq model
  • Sheet: row 1 must hold date, service, details, amount, category, currency, payment and source, or the sheet step stops
  • Card: the field is free text in this copy, so add your own list to the schema if you want fixed names
  • Not run: Mindket did not run it against Gmail, Gemini, Groq or Google Sheets
  • Credentials: the JSON holds none

README and files

README

Spending emails in Gmail logged to a Google Sheet by AI

An n8n workflow that turns spending emails into rows in a Google Sheet. It watches two Gmail labels, one for invoices and one
for payment notices, and opens any PDF attached to them. An AI model then reads each email and returns the date, the
service, the details, the amount, the category and the currency. Each payment becomes one row.

What is inside

  • workflow.json: the workflow as n8n exports it, twenty-four nodes. Three are sticky notes. It holds no credential.
  • README.md: these notes.

What we changed from the original copy

  • The Gemini chat model asked for gemini-1.5-flash, which Google's model pages no longer list. Google Gemini Chat Model1
    now asks for gemini-3.8-flash, Google's current Flash model.
  • The Groq chat model asked for llama-3.2-11b-text-preview. Groq's deprecation page says that model was replaced by an
    11B vision model, which was shut down in April 2025. Groq Chat Model now asks for llama-3.3-70b-versatile, which
    Groq's models page lists for production.
  • The two Gmail label ids, the password for the PDFs and the address of the author's Google Sheet are gone. They are now the
    placeholders <YOUR_INVOICE_LABEL_ID>, <YOUR_PAYMENT_LABEL_ID>, <YOUR_PDF_PASSWORD> and <YOUR_SHEET_ID>.
  • Switch held the sender addresses of the author's own banks. Its rules now hold the placeholders
    <YOUR_MULTI_PAYMENT_SENDER> and <YOUR_SINGLE_PAYMENT_SENDERS>.
  • The prompt of Extract details named one bank. It now says that 0 means an email with several payments and 1 means an
    email with one payment.
  • The card field listed the author's card names and their last digits. It is now free text, so the model writes the card
    as a short name with four digits, or null.
  • The Google Sheets tab is called Expenses. The original pointed at a tab by its number.
  • The credential names, which held an email address, are gone.

Before you start

  • A Gmail account with two labels, one for invoices and one for payment notices. A Gmail filter can apply each label to
    the right mail on its own.
  • A Google Gemini API key and a Groq API key.
  • A Google Sheet with a tab called Expenses. Row 1 holds these eight names: date, service, details, amount,
    category, currency, payment and source. If one is missing, the sheet step stops and says the column names were
    updated.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. In Get invoice and Get payment, add your Gmail OAuth2 credential and pick the matching label. This replaces the
    two label placeholders.
  3. In Switch, replace <YOUR_MULTI_PAYMENT_SENDER> with the address that sends mail listing several payments, such as a
    daily card summary. In the other two rules, replace <YOUR_SINGLE_PAYMENT_SENDERS> with the senders of one-payment
    mail, separated by |.
  4. If your PDFs are protected, replace <YOUR_PDF_PASSWORD> in Extract invoice and Extract payment. Otherwise the
    placeholder text is passed on, and an unprotected PDF ignores it.
  5. Add a Google Gemini credential in Google Gemini Chat Model1 and a Groq credential in Groq Chat Model.
  6. Add a Google Sheets OAuth2 credential in Send and Send1, and replace <YOUR_SHEET_ID> in both with your sheet's id,
    the part of its address between /d/ and /edit.
  7. Publish the workflow. The two triggers check Gmail every minute.

How a run goes

  1. Get invoice and Get payment pick up new mail with their label and download its attachments. Extract invoice and
    Extract payment read the first attachment as a PDF. An email with no attachment carries on without it.
  2. Invoice data and Payment data join the email's text and the PDF's text. Switch then sorts the mail by sender.
  3. Mail from the multi-payment sender goes to HTML, which picks every element with the class spend-table. Split Out
    makes one item for each, and Set data 0 marks it as type 0.
  4. Mail from the one-payment senders goes to Set data 1, type 1. Both paths meet in Merge and go to Extract details.
    Gemini reads the email and returns the fields, and Send appends the row, with the card in the payment column.
  5. All other mail goes to Set data 2 and Extract details1. Groq reads it, and Send1 appends the row with an empty
    payment.

Change the result

  • Which mail goes where: the three rules in Switch.
  • Which element holds one payment in a multi-payment email: the selector .spend-table in HTML.
  • The categories, the currencies and the other fields: the schemas in Structured Output Parser and
    Structured Output Parser1.
  • How the model reads the mail: the messages in Extract details and Extract details1.
  • The columns: the mapping in Send and Send1, and row 1 of your tab.

Good to know

  • Until you fill in the sender placeholders in Switch, no mail matches the first two rules, so all mail takes the invoice
    path and the Groq model.
  • The email text and the PDF text go to Google for Gemini and to Groq. Check what your labels collect before you turn
    the workflow on.
  • Each email costs one model call. A multi-payment email costs one for each payment it holds.
  • The source column always holds the word n8n.
  • A limit in your Gemini or Groq plan can stop a run. The two extraction chains and the two sheet nodes try again after a
    failure.
  • The HTML selector only works when the sender marks each payment with that class.
  • Mindket did not run this workflow against Gmail, Gemini, Groq or Google Sheets. These notes follow n8n's published node
    code and the providers' own pages, read on 12 November 2026.
Files
NOTICE.md  626 B
README.md  6 KB
workflow.json  34 KB

3 files, 40 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

Nanosaur2-670M

well9472 · Kit

Makes illustrations from text prompts with a small 670M-parameter diffusion model, run through ComfyUI. Built as a low-budget research model for people who wan…

New

Reads handwritten Arabic text from images and returns it as text. A fine-tuned PaddleOCR-VL model for people digitizing Arabic handwriting.

New

Makes video clips from a text prompt or an image plus text, at up to 720P and 24 frames per second, in the Diffusers format for a single consumer GPU.

New

Similar in Finance & accounting

See all in Finance & accounting

Kronos-mini

NeoQuasar · Kit

Forecasts financial candlestick series with a 4.1M-parameter foundation model trained on data from over 45 exchanges. For quant researchers and developers who…

New