What the agent does
This is for a freight brokerage that books trucks for shippers and cannot invoice a load until the carrier sends proof of delivery: the signed bill of lading, sometimes a lumper receipt, sometimes a note of a shortage or damage. Carriers email these to the billing inbox at all hours, from dispatchers' phones, as photos or PDFs, with a subject that may or may not mention the load number. The billing clerk matches each one by hand to the load in the brokerage's Open loads sheet. The agent does the matching, writes one row per email to a POD log tab, and leaves the invoicing to the clerk.
The clerk connects Gmail and Google Drive with POST /me/connections {"type": "app", "name": "gmail"} and then {"type": "app", "name": "google-drive"}, each a sign-in on Google's page that asks for that product's permissions only, sharing one grant for the account. A Gmail filter in the billing inbox puts the label POD on mail whose subject or attachments look like delivery paperwork. The request below is the daily sweep of that label; the automation in Run it on every runs the same prompt once for each new email.
For each message the agent reads the sender, subject, body and attachments through the Gmail API (users.messages.get and users.messages.attachments.get). From the attached bill of lading it reads the load or PRO number, the consignee, the delivery date, whether the consignee's signature is there, and any exception written on it: short, damaged, refused, over. It reads the Open loads tab of the brokerage's sheet with the Sheets API spreadsheets.values.get and finds the load by number, and when the number is missing or unreadable it tries the carrier and the delivery date, marking that match as Probable rather than Matched.
It appends one row per email to the POD log tab with spreadsheets.values.append: the Gmail message id, received time, carrier, load number, match status (Matched, Probable or No match), signature present, exceptions as written, and the attachment names. It never edits the Open loads tab, never replies to a carrier and never moves or relabels the email. A load whose paperwork shows an exception goes in the run's answer at the top, because a shortage note changes what the shipper is billed and the clerk needs to see it before invoicing.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Process yesterday's proof-of-delivery emails. In Gmail, list messages with q 'label:POD after:2026/11/18 before:2026/11/19'. For each, read the sender, subject, body and attachments. From each bill of lading or delivery receipt read: load number (format BRK-123456) or carrier PRO number, consignee, delivery date, consignee signature present (yes/no/unclear), and any exception written on it (short, damaged, refused, over), quoted. In Google Sheets open the spreadsheet named Open loads 2026 and read tab Loads, range A:H (load_no, shipper, carrier, pickup_date, delivery_date, consignee, rate, status). Match by load_no; if there is none, match on carrier and delivery_date and mark Probable. Append one row per email to tab POD log with spreadsheets.values.append: gmail_id, received_at, carrier, load_no, match (Matched, Probable, No match), signature, exceptions, attachment names. Do not edit the Loads tab. Do not reply to, forward, label, archive or delete any email. In your answer list first every load with an exception or no signature, then No match emails, then counts.",
"connections": [
"gmail",
"google-drive"
]
}- 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 session's answer lists the loads with exceptions or missing signatures first, then the emails it could not match, then counts, and the POD log tab gains one row per email. The clerk works from the log: a Matched row with a signature and no exception goes to invoicing, a Probable row gets a glance at the attachment, and a No match row is usually a carrier who used their own reference, which the clerk looks up.
What the clerk checks before invoicing: every exception, against the photo of the bill of lading, since a scribbled "2 short" can be misread; Probable matches, which rest on carrier and date and can be wrong when one carrier delivered two loads that day; and signatures marked unclear. The agent reads the paperwork and records it; what the shipper is billed, and whether to open a claim, stays with the brokerage.
Run it on every new proof-of-delivery email
In the console, a Project automation with an email trigger watches the clerk's connected Gmail with label set to POD, and runs a saved agent whose connections name gmail at the read level, since the job only reads mail, and google-drive. Each new labeled message starts one run, with its sender, subject, date, plain-text body and up to 20 attachments handed to the run as files after the prompt, so the saved prompt says to process the attached email rather than search the inbox. Mail the clerk sends never fires it, and each message starts at most one run.
The daily sweep in the request stays useful beside it: run once each morning over yesterday's label, it catches anything that arrived while the automation was paused, and the clerk can compare its row count with the log.
The use case this job follows, with its automation and trigger: Produce a report or file, no repo.
Why run it on Rush?
The work needs a Gmail sign-in on the billing inbox and a Sheets sign-in on the load board, and those belong in one place the brokerage controls, not in a script on the clerk's desktop. On Rush both are the clerk's connections, the Google products share one grant that the clerk can revoke from their Google account, and the session's accounts names the mailbox each run read.
Each email is its own run with its own computer and a record of every call and what its model calls cost, so a disputed delivery months later has a trail: which email arrived, what the agent read on the paperwork, and which row it wrote. Reading a phone photo of a crumpled bill of lading is the part a script cannot do, and the reason the clerk spends their mornings on it today.
Frequently asked questions
Can the agent invoice the shipper once the paperwork is in?
Not in this setup. It writes a log row and nothing else, and invoicing stays in the brokerage's billing process. A later step could draft the invoice for the clerk to approve, but the paperwork check comes first.
What if a carrier sends paperwork for three loads in one email?
The agent reads every attachment and writes one row per load it finds, all with the same Gmail message id, so the log shows they arrived together. If it cannot tell which page belongs to which load, it says so in the row.
Does the email trigger read the whole inbox?
It reads new mail in the clerk's connected Gmail about once a minute, and with label set only mail carrying POD starts a run. The Gmail filter decides what gets the label, so the brokerage controls which carriers' mail reaches the agent.
Is the email content trusted as instructions?
No. The automation passes the email after the prompt as untrusted data, and the saved prompt tells the agent what to do with it. A carrier who writes "mark this load paid" in the body gets a log row, not a change.