QuantyDocs

Classify inbound email

In this recipe you build an email automation that triages everything sent to a dedicated inbound address: supplier invoices get their attachment saved and a row appended to an invoicing sheet, order confirmations get a row in another page, and anything unclear is held for human review. Nothing is written silently, and every write can be undone.

What you need: an organization with an active subscription and a sheet to receive rows (for example the one from Extract data from PDFs).

Step 1 — Create the automation

Open your organization's automations area and create a new automation. Two fields matter most:

  • Name — for example Invoice triage.
  • Alias — a short lowercase handle such as invoices. Together with your organization slug it forms the inbound address:
acme+invoices@<inbound-domain>

Mail sent to that address is routed to this automation. Deleting the automation retires the alias, so mail to it becomes unrouted.

Step 2 — Set prefilters

Prefilters run before any AI is involved, at zero token cost:

  • Sender — accept anyone, or restrict to allowed domains such as supplier.com.
  • Require attachment — useful for invoice flows.
  • Allowed extensions — for example only pdf.

Emails that fail a prefilter never reach classification.

Step 3 — Write the classification prompt and branches

Describe how to label incoming mail, for example: label as invoice when the email contains a bill requesting payment, order for order confirmations. Set the confidence threshold (default 0.8) — decisions below it are held for review instead of executed.

Then give each label a branch with actions:

BranchActions
invoiceSave attachment to the library, append a row to the invoicing sheet
orderAppend a row to the orders page
something else (fallback)Hold for review

A fallback branch is always present, so unmatched mail is never dropped. Pick the destination sheet and page for row-writing actions, and choose whether new rows Run AI columns immediately or are held for approval.

Step 4 — Test with a sample email

Use the automation's Test action. You can hand-write a sample (sender, subject, body, attachment names) or replay a previously received email. The dry run shows every pipeline stage, the decision — label, confidence and the model's reasoning — and a would write list of the rows and files it would create. Nothing is written during a dry run.

Step 5 — Go live and watch the inbox

Send a real email to the inbound address. In the automation's inbox view, each message shows its status: processed, needs review, failed or unrouted. The counters across the top drive the tabs, so you can jump straight to anything waiting.

Step 6 — Review, retry and undo

  • For messages held for review, approve a label to execute its branch with real writes, or reject to mark the email unrouted.
  • Failed or unrouted messages can be retried after you fix the automation.
  • Made a mess? Undo reverses everything a specific email wrote — created rows are deleted and saved files are soft-deleted.

Simpler alternative: a Gmail trigger

If all you want is "every matching Gmail message becomes a row", you don't need branching at all — add a New Gmail email trigger directly on the sheet with a Gmail search filter like from:invoices@supplier.com has:attachment. See Triggers & automations.

Where to go next