After a couple of months, I ran into a few difficulties that would require me to re-think my logic for writing scripts like this.
- The refresh token expires after 7 days so you'd have to keep requesting token. This means this is not really automated anymore. For long lasting accounts, you could use a service account but this requires a GSuite account.
- Found out about Google App Scripts. I'm in the process of migrating all this work into Google App Scripts.
I wanted to automate combining monthly bills to share it with your roommates so I created this script. Let me know what you guys think!
Customizable and extensible way of collecting all your bills before sending out an email with a final receipt to your recipients.
- Fetches Gmails with the labels you provided.
- Runs each email through the scripts (that you provide) to parse the amount. This includes reading and attaching files!
- Adds any additional custom scripts that you may have.
- Finally, composes an email using the parsed data to create a "final" receipt to send to your recipients.
An example of how I use it:
- I get utility bills on my primary email account.
- Forward them to my dev email account. This is to limit what emails you can access using Google API for safety.
- Create filters to label my utility bills by water and electricity.
- Write email scripts to extract the amount.
- Download code on my raspbery pi and schedule it to run every month to send me monthly aggregated bills 🎉.
Check out the GitHub repository for a more extensive writeup.