02

Flexport Discrepancy Analyzer

An inventory analysis workflow that combines Flexport API data with CSV reporting, identifies discrepancies, uses Gemini for analysis, and delivers structured findings by Gmail. It prepares the exceptions. A person decides what to do about them.

Class
Ecommerce Operations
Built with
n8n · Flexport API · Google Gemini · CSV Parsing · Gmail
Walkthrough
Loom recording

The work

Inventory reconciliation means comparing inventory levels, inbound shipments, product catalog information and CSV report data to work out where the records do not agree.

The friction

The difficult part is repeatedly comparing records across several data sources and identifying the exceptions that actually need attention.

n8n workflow canvas for the Flexport Discrepancy Analyzer, showing report token retrieval and CSV parsing, three parallel Flexport API branches for inbound shipments, inventory levels and product catalog, a merge step, Gemini analysis, and Gmail report delivery.
The full n8n canvas. Report retrieval runs first, the three Flexport API calls fan out in parallel, and all of it converges on the merge before analysis and delivery.1798 × 828 · 263 KB

The system

Report retrieval runs first. Three Flexport data sources are then fetched in parallel and merged before anything is analysed.

  1. Manual Execute
  2. Fetch Report Token
  3. Wait for Report
  4. Report Ready?
  5. Download Report CSV
  6. Parse CSV Data
  7. Flexport data, fetched in parallel

    • Fetch Inbound Shipments
    • Fetch Inventory Levels
    • Fetch Product Catalog
  8. Merge All Data
  9. Build Product Alert List
  10. Build AI Prompt
  11. Analyze with Gemini
  12. Format Email Report
  13. Send Gmail Report

What it handles

  • Report-token retrieval
  • Report readiness checking
  • CSV retrieval
  • CSV parsing
  • Flexport API requests
  • Inbound shipment retrieval
  • Inventory-level retrieval
  • Product-catalog retrieval
  • Data merging
  • Discrepancy preparation
  • Product alert preparation
  • AI-assisted analysis
  • Formatted report generation
  • Gmail delivery

What stays human

The report arrives by email. Someone reads it and decides the operational action.

  • Inventory decisions
  • Shipment handling
  • Product record corrections
  • Supply-chain decisions

The principle

The workflow explains the discrepancies. A person decides what to do about them.

Exceptions

These are cases the workflow can meet. It does not correct records on its own.

  • Report not ready
  • Token retrieval failure
  • API failure
  • Missing records
  • Incomplete SKU mappings
  • Malformed CSV data
  • Disagreement between data sources
  • AI analysis requiring additional review

How it improves the workflow

Instead of manually cross-checking every record, the workflow collects, compares and organises the discrepancies that need attention.

Who it’s for

  • E-commerce businesses using Flexport
  • Logistics and supply chain teams
  • Warehouse and inventory managers
  • Operations teams doing manual stock reconciliation
  • Businesses shipping internationally

Walkthrough