File documents by what they contain
Reads each document that arrives by email and files it by what it says - or leaves it for you when it cannot tell.
What it does
Each integration step this workflow runs, in order, what it is for, and the conditions and loops that decide when it runs.
- 1
GmailNew email triggerWakes the workflow when a new email arrives in Gmail, so documents are sorted soon after they land. - 2
GmailList emailsLists inbox mail matching your search that has attachments and does not yet carry the 'Document filing' label. For each
message- 3
GmailFind emailFinds the sender's newest inbox message to confirm this is the one whose attachments Gmail can hand over. - 4
GmailDownload attachmentsDownloads the attachments from the sender's newest message, of which only PDF files are treated as documents. - 5
GmailAdd label to messageMarks each handled email 'Document filing' before anything is copied, and adds 'Needs sorting' when a document cannot be placed. For each
attachment- 6
OpenAIQuery modelAsks the AI to pick exactly one of your folder names from what the document says, or answer UNCLEAR rather than guess. - 7
BoxUpload fileUploads the PDF to the chosen Box folder under its original file name once a folder has been picked with confidence.
- 6
- 3
How it works
What happens on each run, in plain English.
Whenever a new email arrives in Gmail, mail matching your search that carries attachments is swept up, and each PDF is read for what kind of document it is, what it concerns, its reference, its date and any total. The AI then picks one of the Box folders you have described from those answers alone: the sender and subject line are never shown to it, so an invoice is filed as an invoice whoever sent it.
Each filed copy lands in its Box folder under the original file name. When the answer is not exactly one of your folder names, or the document could not be read, nothing is copied and the email is labelled 'Needs sorting' so you have a short queue to work through. Mail is marked as handled before anything is copied, so a run that dies part way leaves a copy missing and reported, never the same contract in two folders. Only PDF attachments count as documents.
Each folder is described in advance with a name, its Box folder and a line saying what belongs there.
Start from a workflow that already works.
Add "File documents by what they contain" to your workspace, connect its apps, and make it yours. No credit card required.
Free plan available · No credit card required
