Inspiration

Small and mid-sized e-commerce merchants lose thousands of dollars every year to "Item Not Received" chargebacks and PayPal disputes—not because they failed to ship, but because assembling carrier evidence, verifying delivery records, and writing compliant responses under strict deadlines takes hours of manual work. At the same time, fighting a dispute when the merchant genuinely made a fulfillment mistake (such as shipping an empty box or damaged item) triggers chargeback fees and damages seller account standing. We built Dispute Desk AI (Autonomous Fraud Defense Copilot) to act as an intelligent, hallucination-proof operations copilot directly inside the merchant's order workflow.

What it does

  • End-to-End Storefront & Order Capture: Buyers browse a live e-commerce catalog and complete checkout via the PayPal REST API, automatically recording verified order IDs, capture IDs, and courier tracking (FEDEX) in a relational database.
  • Autonomous Dispute Triage: When a dispute arrives, Google Gemini cross-references the claim against order and shipping records to recommend either FIGHT (backed by proof of fulfillment) or ACCEPT (full refund).
  • Deterministic Integrity Guard: Before any AI-generated response is approved, a rule-based verification layer audits the draft against SQLite shipping records—blocking fabricated signature confirmations, mismatched tracking numbers, or unsupported delivery claims.
  • Conversational Strategy Pivot: Through the live Dispute AI Copilot chat drawer, merchants can ask case-specific questions or report operational errors (e.g., "We accidentally shipped an empty box"). The Copilot immediately overrides raw tracking data, pivots the strategy from FIGHT to ACCEPT, and executes the resolution via PayPal.
  • Audit Logging & Session Hardening: Every AI recommendation, Integrity Guard verdict, and PayPal API action is persisted to an immutable audit log, protected by strict Cache-Control: no-store headers and history guards.

How we built it

  • Backend & Persistence: Built with Node.js, Express, and Better-SQLite3 (disputes.db) across normalized tables (users, orders, shipping_records, disputes, ai_decisions, and audit_log).
  • AI & Hallucination Defense: Powered by the @google/genai SDK (gemini-3.8-flash with automatic fallback to gemini-3.5-flash-lite and a DB-grounded resilience engine) paired with a deterministic verifyAiDraft Integrity Guard. We model the merchant's expected dispute payoff as:

$$\mathbb{E}[\text{Payoff}] = P(\text{Win} \mid E) \cdot V_{\text{order}} - \big(1 - P(\text{Win} \mid E)\big) \cdot (V_{\text{order}} + F_{\text{fee}})$$

where $E$ represents verified shipping evidence in SQLite, $V_{\text{order}}$ is the disputed transaction amount, and $F_{\text{fee}}$ is the dispute penalty cost—driving the Copilot's dynamic pivot between FIGHT and ACCEPT.

  • Payments & Dispute Execution: Integrated PayPal Checkout v2 (/v2/checkout/orders) and PayPal Customer Disputes v1 (/v1/customer/disputes, /provide-evidence, and /accept-claim) with graceful sandbox resilience.

Challenges we faced

  • Preventing LLM Hallucinations in Financial Disputes: Early prompts occasionally caused the model to assume signature confirmation when only standard carrier tracking existed. We solved this by building a deterministic Integrity Guard that parses every AI draft against SQLite before allowing submission.
  • API Latency & Sandbox Availability: Handling PayPal Sandbox endpoint instability and model demand spikes required engineering multi-model fallback chains, strict request timeouts, and local sandbox simulation handlers so merchant operations never stall.

What we learned

Combining generative AI with deterministic SQLite verification creates trustworthy automation for high-stakes financial workflows—giving merchants the speed of an autonomous agent without sacrificing compliance or accuracy.

What's next for Dispute Desk AI

  • Direct webhook ingestion (CUSTOMER.DISPUTE.CREATED) for zero-click background triage.
  • Automated PDF packing-slip and carrier proof-of-delivery attachment generation for high-value disputes.

Built With

Share this project:

Updates

Submission history