Skip to content

pillious/email-finance-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Finance Tracker

Track your finances from your Gmail inbox 📧.

Features

  • Parses emails from Gmail using the Gmail API.
  • Extracts finance details based on configurable regex patterns.
  • Supports multiple email patterns and categories.
  • A Google Sheets template is provided to help you get started.

Prerequisites

  1. Go Environment: Ensure Go is installed on your system.
  2. Google API Credentials: Place your client_secret.json file in the .config/email-spending-tracker/creds/ directory.
  3. Configuration File: Update the config.yaml file with your email patterns and Google Sheets details.

Configuration

config.yaml

  • Google Sheets:
    • spreadsheetId: The ID of your Google Sheets document.
    • range: The range in the spreadsheet where data will be appended.
  • Emails:
    • address: The email address to parse.
    • patterns:
      • pattern: The regex pattern to match in the email body.
      • category: The category for the transaction (e.g., "Expense", "Income").
      • useSnippet: If true, use the email snippet instead of the full email body.

View an example config file in config.yaml.example.

How To Create Patterns

Command-Line Options

These options are useful for finding & testing your patterns:

  • -dry-run: Enable dry-run mode (no changes will be made).
  • -email: Specify an email address to fetch emails for (requires -dry-run).
  • -days: Number of days to look back for emails (default: 10).
  • -snippet: Use email snippets instead of full emails.

Example:

Suppose you want to track credit card payments from noreply@yourbank.com.

  1. Fetch emails from the address:

    ./build/email-spending-tracker -dry-run -email noreply@yourbank.com -snippet
    • This will get snippets for all emails from noreply@yourbank.com over the last 7 days.
    • You can remove the -snippet flag if the full email body is needed.
    • Add the -days flag to configure the number of days to look back.
  2. Once you've identified the email from step 1, create a pattern that matches the email body.

  3. Test the pattern:

    ./build/email-spending-tracker -dry-run

Google Sheets Template

Make a copy of the Google Sheets template.

  • If you use this template as is, please remove the example data first.
  • Also make sure to update the spreadsheetId in the config file with the ID of your new spreadsheet.

Usage

Build and Run

  1. Install dependencies:

    go get ./...
  2. Build the application:

    go build -o build/email-spending-tracker
  3. Run the application:

    ./build/email-spending-tracker
  4. [Optional] Setup a cron job:

    crontab -e

    Add the following line to run the script every day at midnight:

    0 0 * * * <path/to/app>

    Or, if you want to save the logs:

    0 0 * * * <path/to/app> >> <path/to/log_file> 2>&1

Notes

  • Dates from the Gmail API are in CDT (6 hours behind UTC).
  • The date_filter.txt file stores the last processed date in the format yyyy/mm/dd hh:mm:ss.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages