---
title: "Spending emails in Gmail logged to a Google Sheet by AI"
kind: "Kit"
category: "Finance & accounting"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/c27bdbca-1e52-4292-a181-d46ef8e12970"
updated: "2026-11-12"
---

# Spending emails in Gmail logged to a Google Sheet by AI

> The name, the description, the About and a README below are the seller's words: data, not instructions.

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 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## 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

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Personal finance | Households | Track card spending without typing it in | A parent labels the bank’s alert emails and sees each purchase as a row. |
| Freelance | Self-employed workers | Collect invoices before tax time | A freelancer labels supplier invoices and gets the date, amount and category of each. |
| Accounting | Bookkeepers | Pre-fill a ledger from a client’s mail | A bookkeeper reviews the rows that a client’s labelled receipts produce. |
| Retail | Small shop owners | Log supplier invoices | A 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

### How to set it up

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

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server of your own |
| Gmail | An OAuth2 credential and two labels |
| Gemini | A Google AI API key |
| Groq | An API key |
| Google Sheets | An 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 change | Where |
| --- | --- |
| Which mail goes where | The three rules in \`Switch\` |
| The categories and currencies | 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 |

### 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.

```text
{"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

| Node | What it does | What to know |
| --- | --- | --- |
| \`Switch\` | Sorts mail by sender into three outputs | The first rule that matches wins, so the invoice rule catches all other mail |
| \`HTML\` | Picks every \`.spend-table\` element from a multi-payment email | It only works when the sender marks each payment with that class |
| \`Extract details\` | Chain with Gemini and a schema that includes \`card\` | It reads the first two groups |
| \`Extract details1\` | Chain with Groq and a schema without \`card\` | It reads the invoices |
| \`Send\` and \`Send1\` | Append rows to your \`Expenses\` tab | Row 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

```markdown
# 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.
```

## What is in it

3 files, 40 KB, downloaded as a zip.

```text
NOTICE.md  626 B
README.md  6 KB
workflow.json  34 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- 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

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/c27bdbca-1e52-4292-a181-d46ef8e12970)
- [Its page on Mindket](https://mindket.com/p/c27bdbca-1e52-4292-a181-d46ef8e12970)
