What the agent does
This is for a small freight brokerage: six brokers, a billing coordinator, and a few hundred truckload shipments a month moved by carriers it books. When a load delivers, the carrier emails the signed proof of delivery (POD), usually a phone photo or scan of the bill of lading, to the brokerage's billing inbox, and the billing coordinator cannot invoice the shipper or pay the carrier until someone has read it: is it signed, is it the right load, are there exceptions such as short pieces, damage or a "subject to count" note, and does the delivery date match. The agent reads every POD as it arrives and hands the coordinator a checked summary and a draft bill line, so the clean ones are billed the same day and the problem ones are seen first.
The billing coordinator connects the billing inbox's Gmail once with POST /me/connections {"type": "app", "name": "gmail"}, and the saved agent names it as {"name": "gmail", "access": "read"}, so each of its runs asks Google for gmail.readonly alone when it refreshes the token. A Gmail filter in the billing inbox already adds the label POD to carrier mail with an attachment. A Project automation with an email trigger and label set to POD reads that Gmail about once a minute; Rush's reference says each new message starts one run with its sender, subject, date, plain-text body and up to 20 attachments as the run's files, deduped on its Gmail id, and that mail the coordinator sends never starts one.
On a run the agent opens each attachment and reads the POD: the load or pro number, the shipper and consignee, the delivery date and time, the receiver's printed name and signature, the piece and pallet counts, and every handwritten note. It then searches the same mailbox with the Gmail API's users.messages.list and a q such as "Load 48213" subject:"rate confirmation" for the rate confirmation the brokerage sent the carrier when it booked the load, reads it with users.messages.get, and takes the agreed rate, accessorials (detention, lumper, liftgate), the pickup and delivery appointments and the piece count from it.
It compares the two and writes one result: clean, or exceptions with each one named (no signature, a different load number, fewer pieces delivered than booked, a damage or shortage note, delivery after the appointment, a lumper receipt mentioned but not attached). For a clean POD it drafts the shipper invoice line (load number, lane, delivery date, line haul and accessorials from the rate confirmation) and the carrier payable line, both as text for the coordinator to enter in the brokerage's own system. It replies to nobody, moves no message and changes no label.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "A carrier emailed a proof of delivery for Load 48213 (subject: 'POD - Load 48213 - Dallas TX to Memphis TN'); the delivery receipt is attached as pod-48213.pdf. Read the POD: load or pro number, shipper, consignee, delivery date and time, receiver's printed name, whether it is signed, pieces and pallets, and every handwritten note, quoted exactly. Use the gmail connection: call users.messages.list with q '\"Load 48213\" subject:\"rate confirmation\"' and read the newest match with users.messages.get, taking the agreed line haul, accessorials, pickup and delivery appointments, and booked piece count. Compare them. Return JSON only: {load, status: 'clean' or 'exceptions', exceptions: [string], pod: {...}, rate_confirmation: {message_id, line_haul, accessorials: [{type, amount}], delivery_appointment, pieces}, draft_invoice_line, draft_carrier_payable}. If no rate confirmation is found, set status 'exceptions' and say so; never guess a rate. Read only: never send, reply, forward, label, move or delete any message.",
"connections": [
"gmail"
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
The agent gives each load a verdict, clean or exceptions in plain words, with a draft invoice line and carrier payable for each clean one. Each POD email becomes one session whose result is a short JSON summary of that load: the verdict with each exception, what the POD said, what the rate confirmation said, and the drafts for a clean load. With the automation's notify_each_run on, each finished run reaches the coordinator on its own, and the coordinator works the exceptions first and bills the clean loads from the drafts.
What the coordinator checks before billing or paying: a handwritten note the agent quoted but could not judge, such as "1 pallet refused" next to a full count; a POD photo too blurred to read a signature, which the agent marks rather than passes; a rate that was changed by phone after the rate confirmation was sent; and detention or lumper charges, which need the carrier's receipt. Entering the invoice and the payable stays with the coordinator, in the brokerage's own system.
Run it on every carrier POD email
In the console, a Project automation with an email trigger, label POD, and from listing the carrier domains the brokerage works with, runs a saved agent whose instructions hold the checks above and whose connections name Gmail with read access. The trigger puts the email after the prompt, so the instructions say "the email below" rather than naming a load. Mail from a sender not in from, or whose domain did not pass DMARC at Gmail, starts nothing.
Set the automation's max_runs_per_hour, at most 30, to the busiest hour's POD count. A run past it is created queued and starts when the hour has room, with up to one more hour's worth waiting, and an event past that is refused, so a brokerage whose Monday mornings bring more PODs than that adds a second label and automation for its largest carriers.
The use case this job follows, with its automation and trigger: Produce a report or file, no repo.
Why run it on Rush?
The Gmail sign-in stays in Rush's connection, read-only, and no forwarding rule sends delivery documents to a third-party address. Each POD gets its own computer, where the scan is opened and read, and its own record of what it read and which rate confirmation it matched, so when a shipper disputes an invoice, the brokerage opens the session and sees the receipt and the agreed rate side by side.
PODs arrive all day and in bursts after weekends, and the work is the same each time: read, find, compare. Each email starts its own run, so ten PODs at once are ten runs, each with its own total_cost_usd, rather than one queue a person works through before invoices go out.
Frequently asked questions
What if the carrier sends the POD as a link to their portal?
The run receives the email's attachments, not files behind a link, and with read-only Gmail it cannot sign in to a carrier portal. The agent returns exceptions with the link quoted, and the coordinator downloads the POD and forwards it to the inbox, where the label starts a new run.
Can one email carry several loads' PODs?
Yes: the trigger passes up to 20 attachments as the run's files. The prompt can ask for one entry per load found in the attachments, each checked against its own rate confirmation, and the JSON becomes a list.
Does this replace our transportation management system?
No. The agent reads mail and drafts lines; the brokerage's own system still holds the loads, invoices and carrier payments. A brokerage whose system has an API can have its own server read the session's result and create the invoice as a draft for approval.
Why read-only Gmail access?
The job only reads. Naming Gmail with access read on the saved agent means its runs ask Google for reading mail and nothing else, and the prompt forbids replies too, so a carrier never gets an email nobody at the brokerage wrote.
More Gmail jobs
More jobs like this: Produce a report or file, no repo
- Did Anything We Sell Get Recalled This Week? An Independent Toy Shop's Monday Check of New CPSC Recalls (Public websites)
- Which Ports and Terminals Changed Their Hours or Closed Today? A Freight Forwarder's Morning Advisory Check (Public websites)
- How Does a General Contractor Check Every Subcontractor's License Each Month? An Agent That Looks Each One Up on the State Board's Site (Web)