Streamlining Tax Season with a Simple Email Hack

Streamlining Tax Season with a Simple Email Hack
Photo by Kelly Sikkema / Unsplash

Every year, as tax season rolls around, I find myself frantically looking through emails and apps to track down tax-deductible expenses. It’s always such a mess. It's like a scavenger hunt, except the prize is just getting my taxes done. So last night, inspired by the annual hassle, I thought, "Why not make this easier for next year?"

The idea? Create a system that automatically sorts and logs my receipts as they hit my inbox. No more digging through old emails, no more second-guessing if I tagged something months ago. I just forward my receipts to a special email address, and poof—they’re organized into a spreadsheet. When it’s time to do my taxes, all I or my accountant need to do is check out a single, tidy file.

Here’s how I set it up:

1. Listening for Emails: I spun up a Flask app that listens for incoming emails. I hooked it up with Postmark's Inbound Email Processing to funnel these emails directly to my app. This part went surprisingly smooth and was easier than when I tried other services before.

2. Grabbing What Matters: Once the emails were rolling in, I needed to pull out important details like who I paid, how much, and when.For this, I used OpenAI’s API (using their official Python SDK) to parse the email content and extract these crucial pieces of information.

Pulling the data out was a bit tricky at first. I was using ChatGPT kind of like a coding buddy to help figure out the exact syntax for the OpenAI API. But it turned out, it was using a deprecated version of the python sdk. To fix it, I ended up checking out the official Python SDK docs on GitHub to get the right code. Once I made those tweaks, grabbing the vendor names, amounts, and dates from the emails went pretty smoothly.

3. The Spreadsheet Bit: The last step—getting all this info into Google Sheets—proved more challenging than expected. I tried using Retool to skip some of the coding, but ran into some snags with authentication. I'm still working out the kinks in this part of the process.

This little project is definitely still a work in progress. I still need to nail down the spreadsheet integration. I may have to dive in and manually code this part using the Google Sheets API. But even with that task looming, I’m feeling pretty good. Just getting the email capture and data extraction pieces up and running has been a big win. It’s given me a glimpse of how, once this whole setup is dialed in, it will seriously streamline how I keep track of tax-deductible expenses all year long. 

In the meantime, if you wanna give this a shot yourself, I’ve put the code up on GitHub. Just remember to plug your own OpenAI API key into the file to get started.