Handle shipping documents that arrive by email
Most shipping documents still reach a forwarder by email: a shipper or supplier sends the commercial invoice and packing list to a documents mailbox, and someone opens each one, checks that both are there and that they agree, and writes back when they don’t. This recipe does that first pass. A person sees an email only when the documents disagree, and the shipper hears back in the same thread.
It doesn’t decide what the documents mean for the declaration or the booking. That stays with whoever is accountable for them. For the blocks themselves, see Receive and send email.
1. Give documents their own mailbox
Section titled “1. Give documents their own mailbox”Connect the mailbox shippers already send documents to, as an Outlook email account or Gmail account, with Allow sending on so the automation can reply. If shippers send to a person’s own inbox today, give them a documents address instead: the automation reads the whole Inbox of the mailbox it’s connected to.
Mark your regular shippers as safe senders in that mailbox. Email that lands in Junk or Spam starts no run.
2. Choose which emails start a run
Section titled “2. Choose which emails start a run”On Email received, turn on Only with attachments, and keep Skip automatic replies on so out-of-office replies to your own emails start nothing.
Don’t filter on Subject to find bookings. Shippers write subjects their own way, and a reference in the subject is often missing or mistyped. Filter on who sends instead:
| You want | Filter |
|---|---|
| One automation per large shipper | From Ends with the shipper’s domain |
| Documents your own team forwards | From Ends with your own domain |
| Everything except one system’s notices | From Does not equal that system’s address |
| Only what was sent to the documents alias | To Contains the alias, when the mailbox has more than one |
Emails that don’t match start no run and aren’t stored. The trigger shows how many it filtered out in the last 7 days, so a filter that is too tight shows up there.
3. Sort and read the documents
Section titled “3. Sort and read the documents”Add AI Agent with Attachments as its Files. Put Subject and Body Text in the User message: shippers often write the booking or order reference there and not on the documents.
Set Answer format to JSON and ask for:
- which file is the invoice and which the packing list,
- a text field such as missingDocuments that names any document that isn’t there, and is empty when both are,
- the reference, and where it was found: the documents, the subject or the body,
- the lines of each document, for the comparison.
Tell it in the System message to copy values as printed and never fill a line it can’t read. See Read data from a document for the answer shape and the limits on files.
4. Ask for what’s missing
Section titled “4. Ask for what’s missing”Add a Condition that checks the answer’s missingDocuments with Is empty. On False, add Reply to email with the trigger’s Message Id, and a short Body that names what is missing, for example:
Thank you. We received your email about @reference, but could not find: @missingDocuments.Please reply with the commercial invoice and the packing list attached together.Type @ in Body to put in the reference and the missing documents from the answer.
Ask for both documents in the reply, not only the missing one. The shipper’s answer starts a new run, which reads only the files in that email.
Leave Reply to all off. Shippers often copy in their own customers or agents, who don’t need to hear about a missing document.
5. Compare the two documents
Section titled “5. Compare the two documents”Add Checklist after True, with the invoice lines and packing list lines from the answer. Compare a commercial invoice with a packing list covers what to match on and how much difference to allow.
Set Ask a person to When a check fails, and add the email’s Attachments as Source documents, so the reviewer sees the documents next to the differences.
- Approved or Bypassed: the documents agree, or a person accepted the differences. Carry on, for example to find or create the BoxTop job and attach the documents.
- Rejected: add a second Reply to email asking for corrected documents. Its text is fixed, so it says that the documents disagree and asks for both again. It doesn’t carry the reviewer’s notes. If the shipper needs the details, the reviewer writes to them.
What goes wrong
Section titled “What goes wrong”- The reply goes nowhere. Booking platforms and supplier systems often send from a no-reply address, and a reply goes to From. The bounce comes back as a delivery failure, which starts no run, so nobody notices. Filter those senders into an automation that asks a person instead of replying.
- A spreadsheet packing list. AI Agent reads PDFs, images and plain text such as CSV. An Excel workbook makes the step fail, and the run with it. The same happens with an email forwarded as an attachment. Decide who picks up those failures with Set Assignees, and ask regular shippers for PDFs.
- Too many files. Signature logos and banners sent as attachments count as files and go to the model too. One AI Agent step takes up to 10 files and 20 MB of PDFs and images in total.
- The same documents twice. A shipper who resends, or a colleague who forwards the same email, starts another run. Make the next step safe to repeat, as Find or create BoxTop job is.
- A large scan pack. An email over about 50 MB, counting encoding, isn’t processed at all. The trigger counts it as too large to process, and the shipper gets no answer. Check that count, and ask shippers to split very large packs.
- Too many replies. A connection sends up to 500 emails a day, replies included. A shipper system that sends hundreds of notices to the documents mailbox can use that up, so filter it out on From.