An autonomous n8n workflow built to automate the manual validation of daily shipment records and instantly generate dynamic shipping manifest PDFs to prevent dispatch delays.
To eliminate manual data entry for a fast-growing logistics company, ensuring zero dispatch errors while processing high volumes of unstructured shipment data.
- Workflow Engine: n8n
- AI/LLM: OpenAI API (Agentic Validation & Structured Output Parsing)
- Document Generation: PDFMonkey API
- Database & Storage: Google Sheets, Google Drive
- Communication: Gmail API
graph LR
%% Trigger and Loop
Trigger([Google Sheets Trigger<br/>⚡ rowAdded]) --> Loop(Loop Over Items)
%% AI Agent Node & Its Dependencies
Model((OpenAI Chat Model)) -.->|Model| Agent[Validate Shipment details]
Context[(Carrier Details<br/>Read Sheet)] -.->|Data| Agent
Parser{{Structured Output Parser}} -.->|Parser| Agent
Loop -->|loop| Agent
Agent --> Cond{If Validate}
%% True Branch (Validation Successful)
Cond -->|true| SetData[Set Shipment Data<br/>Manual]
SetData --> PDFGen[PDF Generate<br/>PDFMonkey]
PDFGen --> GetPDF[Get PDF]
GetPDF --> EmailSender[Send Shipment PDF<br/>To Sender]
EmailSender --> EmailReceiver[Send Shipment PDF<br/>To Receiver]
EmailReceiver --> Download[Download File]
Download --> UploadDrive[Upload file<br/>Google Drive]
UploadDrive --> UpdateSheet[Append or update row<br/>in sheet]
%% Loop back to next item
UpdateSheet -->|Next Item| Loop
%% False Branch (Validation Failed / Mismatch)
Cond -->|false| MismatchEmail[Send Mismatch Items<br/>Details via Gmail]
MismatchEmail --> UpdateState[Update State<br/>Append/Update Sheet]
%% Loop back to next item from false branch
UpdateState -->|Next Item| Loop
%% End of Loop
Loop -.->|done| End([End Workflow])
%% Styling to match node types (Optional but looks good)
classDef trigger fill:#0b8a5b,stroke:#065f3d,stroke-width:2px,color:#fff;
classDef ai fill:#7c3aed,stroke:#5b21b6,stroke-width:2px,color:#fff;
classDef logic fill:#0ea5e9,stroke:#0369a1,stroke-width:2px,color:#fff;
classDef external fill:#f43f5e,stroke:#be123c,stroke-width:2px,color:#fff;
classDef sheets fill:#10b981,stroke:#047857,stroke-width:2px,color:#fff;
class Trigger,UpdateSheet,UpdateState,Context sheets;
class Agent,Model,Parser ai;
class Loop,Cond,SetData logic;
class PDFGen,GetPDF,EmailSender,EmailReceiver,MismatchEmail,Download,UploadDrive external;
- Trigger: Workflow initiates upon a new entry in Google Sheets.
- AI Validation: An OpenAI agent cross-references unstructured raw shipment data with carrier databases.
- Conditional Routing:
- Match (True): Generates a dynamic PDF via PDFMonkey, uploads to Drive, and emails the sender/receiver.
- Mismatch (False): Instantly sends an alert containing the mismatched data for manual review.
- Time Saved: 40+ hours per week for the operations team.
- Accuracy: Reduced dispatch errors to zero.
- Scalability: Allowed the client to scale shipment volume 10x seamlessly without adding operational headcount.
Developed by Uba Chan