n8n Workflow
Intermediate

Automate Expense Tracking from Emails to Google Sheets

Automate your expense tracking by scanning receipts from emails using Mindee OCR and adding them as new rows in a Google Sheet. Eliminate manual data entry for expenses.

Overview

Automatically scans email attachments for receipts, extracts expense data using OCR, and logs it into a Google Sheet for effortless expense management.

🧠 Description & Use Case

This workflow automates the process of expense tracking by connecting your email inbox to a Google Sheet. It scans for emails containing receipts, uses Optical Character Recognition (OCR) to extract the data, and logs it in a spreadsheet, eliminating manual data entry.

🔄 How It Works:

  1. Check for New Emails: The workflow starts by connecting to your email server via IMAP and fetching new, unread emails from your inbox.
  2. Filter for Expenses: It checks if the email's subject line contains keywords like "expenses" or "receipt". This ensures that only relevant emails are processed.
  3. Extract Data from Receipt: For matching emails, the workflow sends the first attachment (assumed to be the receipt) to the Mindee API. Mindee's specialized OCR for receipts scans the document and extracts structured data like the total amount, date, currency, and expense category.
  4. Format the Data: The workflow then organizes the extracted information. It maps the data from Mindee (date, category, currency, total) and the email (subject for description) into a clean format ready for the spreadsheet.
  5. Add to Google Sheet: Finally, it appends all the formatted information as a new row to your specified Google Sheet, creating a perfectly organized log of your expenses.

✅ Real-World Use Cases:

  • Personal Finance: Automatically track all your online purchase receipts and personal expenses without ever having to open a spreadsheet.
  • Freelancers & Consultants: Effortlessly log business expenses for tax purposes. Just forward your receipts to a dedicated email address, and the workflow handles the rest.
  • Small Business Accounting: Streamline the expense reporting process for your team. Employees can email their receipts, and they will be automatically logged for review by the finance department.
  • Project Budgeting: Keep a real-time record of project-related expenditures by tracking receipts sent via email.

Instructions

Basic steps

  1. Download workflow JSON
  2. Import into n8n
  3. Configure node parameters as needed
  4. Test and enable the workflow

💡 Tips

After importing, verify all connectors and credentials match your environment.

Preview

Workflow Visualization

6 nodes
100%
Check subjectifSetup VariablessetCheck for new emailsemailReadImapRead ReceiptsmindeeSet column datasetAdd to Google SheetgoogleSheets

Nodes

1

Check subject

if

v1
2

Setup Variables

set

v1
3

Check for new emails

emailReadImap

v1
4

Read Receipts

mindee

v1
5

Set column data

set

v1
6

Add to Google Sheet

googleSheets

v1

Statistics

Total nodes:6
Disabled nodes:0
Node types:5
Connections:5
View full JSON structure
{
  "nodes": [
    {
      "name": "Check subject",
      "type": "n8n-nodes-base.if",
      "position": [
        800,
        300
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"subject\"].toLowerCase()}}",
              "value2": "=/{{$json[\"subjectPatterns\"].toLowerCase()}}/",
              "operation": "regex"
            }
          ]
        },
        "combineOperation": "any"
      },
      "typeVersion": 1
    },
    {
      "name": "Setup Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        620,
        300
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "subjectPatterns",
              "value": "(expenses|reciept)"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "name": "Check for new emails",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        440,
        300
      ],
      "parameters": {
        "format": "resolved",
        "mailbox": "Inbox",
        "options": {
          "allowUnauthorizedCerts": true
        }
      },
      "credentials": {
        "imap": {
          "id": "24",
          "name": "GMAIL"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "Read Receipts",
      "type": "n8n-nodes-base.mindee",
      "position": [
        1020,
        280
      ],
      "parameters": {
        "binaryPropertyName": "attachment_0"
      },
      "credentials": {
        "mindeeReceiptApi": {
          "id": "61",
          "name": "Mindee Receipt account"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "Set column data",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        280
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Date",
              "value": "={{$json[\"date\"]}}"
            },
            {
              "name": "Description",
              "value": "={{$node[\"Check for new emails\"].json[\"subject\"].split(\"-\")[1]}}"
            },
            {
              "name": "Category",
              "value": "={{$json[\"category\"]}}"
            },
            {
              "name": "Currency",
              "value": "={{$json[\"currency\"]}}"
            },
            {
              "name": "Amount",
              "value": "={{$json[\"total\"]}}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "name": "Add to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1380,
        280
      ],
      "parameters": {
        "range": "A:E",
        "options": {},
        "sheetId": "1xAtx1ORZYKu4urgqpOe3DawFjiWeOZO0VCVvOlQYnaE",
        "operation": "append",
        "authentication": "oAuth2"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8",
          "name": "Sheets"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Check subject": {
      "main": [
        [
          {
            "node": "Read Receipts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Receipts": {
      "main": [
        [
          {
            "node": "Set column data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set column data": {
      "main": [
        [
          {
            "node": "Add to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup Variables": {
      "main": [
        [
          {
            "node": "Check subject",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for new emails": {
      "main": [
        [
          {
            "node": "Setup Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Actions

Share
Categories:
Tags:
ifsetgooglesheetsmindeeemailreadimap

Technical Specs

Complexity:
Intermediate
Node Count:
6 nodes
Published:11 months ago
Updated:9 days ago

Compatibility

Platform:
N8N Cloud & Self-hosted
Min Version:
N8N v1.0.0+
Supports cloud and self-hosted deployment

License

This workflow template follows MIT license, you can freely use, modify and distribute.

Please comply with relevant third-party service terms when using.

Related Workflows