All workflows
Gmail logoBox logoGoogle Sheets logoOpenAI logo

File emailed documents and log what they say

Files every document that arrives by email into Box and records what it says as a row on your register.

On new email in Gmail4 apps9 steps

Apps it connects

Authenticate each one once and the workflow is ready to run.

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. 1GmailNew email triggerWakes the workflow when a new email arrives in Gmail, optionally only from a sender you name on the trigger.
  2. 2GmailList emailsLists up to 25 inbox messages matching your search that have attachments and carry neither the register label nor the 'Needs filing' label.
  3. For each message

    1. Try

      1. If senderAddress contains “@”

        1. 3GmailFind emailChecks that each message is still the sender's newest in the inbox, since only that one's attachments can be opened.
        2. If latestId is messageId

          1. 4GmailDownload attachmentsDownloads the attachments from the sender's latest message, keeping only PDFs as documents to file.
          2. For each attachment

            1. Try

              1. 5BoxUpload fileUploads each PDF into your Box folder under its own name plus a reference to its email, so a name used before never clashes, and keeps the link for the register.

              If a step fails

              1. 6BoxList folder itemsOnly when an upload is refused: looks for a copy this same email already left in the folder on an earlier run, and uses it rather than failing.
            2. 7Google SheetsAppend rowAppends one register row per document, written exactly as read: filed time, sender, subject, file name, Box link, read status and each extracted field.
      2. 8GmailAdd label to messageLabels an email as registered once every document on it is filed and logged, or 'Needs filing' when it could not be finished, so it is never handled twice.

      If a step fails

      1. 9GmailAdd label to message

How it works

What happens on each run, in plain English.

Whenever new mail arrives in Gmail, the workflow sweeps your inbox for messages matching a search you describe, copies the PDF attachments on each into a Box folder and adds one row per document to a register in Google Sheets. The row records when it was filed, the sender, the subject, the name it was filed under, a link to the copy and whether it could be read, followed by details read from the document itself, such as a supplier, document number, date and total, written exactly as the document gives them.

A field the document does not carry is left empty rather than guessed. Each copy keeps its own name plus a reference to its email, so this month's Invoice.pdf never collides with last month's. An email is labelled as registered only once every document on it is copied and logged. One that cannot be finished, such as an older email from a sender whose newer one is still in the inbox, is labelled 'Needs filing' for you, and any problem, including a document that could not be read, ends the run marked as failed with a note of what to do.

You need Gmail, Box, Google Sheets and OpenAI connected, a Box folder to file into, and a spreadsheet tab whose column headings match the row. Fill in the Gmail search, the Box folder and the spreadsheet link; everything else has a working default.

gmailboxgoogle sheetsdocumentsinvoicesattachmentsfiling

Start from a workflow that already works.

Add "File emailed documents and log what they say" to your workspace, connect its apps, and make it yours.

Free plan, no credit card