My goal is to automatically save all the invoices from various services arriving in my Gmail, organized by the month they’re received, into their corresponding Google Drive folders.
For example, if I receive an invoice from Google Workspace and another from Make.com in December, I want to save these invoice files in a folder named ‘12_December’ or similar, aligning the folder’s name with the month.
Here are the steps I believe are necessary, though I’m unsure how to integrate them:
- watch for incoming emails.
- identify the date and filter emails by various subjects/phrases to isolate those containing invoices.
- direct the invoices to the folder matching their date (I can create all 12 folders beforehand and name them as needed to make the process as simple as possible).
Does anyone have any suggestions? (I’m not sure if the last one is even possible)
Hey @Filip3000,
This is definitely possible. I would approach this this way:
- Create filters in Gmail to label invoices using a unique label, like “Invoice”.
- In Make, use a Gmail Watch Emails module to monitor new emails with that label. This way you don’t use up Ops monitoring every single email.
- Get the date from the email, generate your sub-folder name, then search Google Drive for the folder. You can use formatDate() on a date to create a unique string. For example, use the format MM_MMMM to create 12_December.
- If the folder doesn’t exist, create it.
- Extract the attachment from the email, and drop it into the Google Drive folder you located or created.
Not 100% sure it will all work like this, but I’d at least start this way and see how it goes. Good luck!
4 Likes
(Re: bullet points 3 & 4 above)
You can use this trick to see if a Folder’s Path (your monthly folder) exists first before creating a duplicate when multiple invoices are received in the same month.
4 Likes
@Donald_Mitchell, @samliew Awesome, it’s working – thanks a lot for your help!
No problem, glad I could help! Thanks for letting us know you managed to get it working.
If possible, would you be able to contribute back to this community by sharing what you did?
1 Like
@samliew Right, my bad.
Here is what I did (which is basically following the advice I got here):
- Set up filters in Gmail so the targeted emails have a specific label
- Use Watch emails module to watch for the unread, labeled emails (after running it through Make they are marked as read – personal preference)
- Use Iterator to handle multiple attachments
- Search for Google Drive folder with Fulltext Search and a custom query: formatDate({email-date} “MM MMMM”)
- Use Router to check if the folder exist
- If not, create the folder with Create a Folder module and pass the invoice with Upload the File module (if the folder exists, skip the creation).
Here’s the scenario:
blueprint-gmail-gdrive.json (23.7 KB)
3 Likes
Cool! I forgot to mention something initially about how I build mine out…
The difference is that after the router, I have three routes:
- Folder found - Store the Folder ID in a variable.
- Folder not found - Create it and store the Folder ID in a variable.
- All cases - retrieve the Folder ID from variable, then upload the file.
This has the benefit of having only 1 Upload File module to worry about in case future updates are needed.
And, since there’s only 1 Upload File module, there’s only 1 place I need to get the file if I need to use it downstream.
The downsides are that it looks more complicated and uses more Ops, but in my case it is worth it because I’ve burned myself before by forgetting to update multiple Upload a File modules when something had to change.
4 Likes