-
-
A lowball is refused by code. "Fix my Python code" gets a redirect with no AI call.
-
Safety check: hundreds of hostile negotiations against a misbehaving AI, zero rule violations.
-
The buyer's orders in one place, with each payment's PayPal status: paid, refunded, hold released.
-
The seller Copilot reads real PayPal transactions over PayPal's MCP server (transport shown: mcp).
-
Deal closed: the price is locked on the server and held while the buyer checks out with PayPal (Sandbox).
-
Five haggler personalities change voice and pace only, never the seller's price floor.
-
Every deal's PayPal money trail: order, authorization, capture and PayPal webhooks marked "signature verified".
Inspiration
Small sellers get asked for a discount all day. Say yes too fast and you lose margin; replying to everyone takes time. We wanted an AI that can haggle for the seller without ever being able to give the shop away.
What it does
- Buyers chat with the shop's AI, make offers, accept a counter-offer and pay the exact agreed price with PayPal (Sandbox). Or they send their own AI agent to haggle for them with a maximum price they set (also enforced in code).
- Sellers set cost, minimum margin, maximum discount and stock for each product, pick a haggler personality (Friendly, Firm, Generous, Playful, Market trader: voice and pace only, never the price floor), see every deal's PayPal money trail, add shipment tracking, and run a safety check of hundreds of hostile negotiations.
- Agents can use an open negotiation API (
haggle.v1) and are held to the same guardrails. - Off-topic, spam and abuse never reach the AI. Code questions ("fix my Python code"), gibberish, random words and abuse get a short in-voice redirect from plain code: no model call, no change to the price.
The central idea: the AI proposes, plain code decides. The seller's floor price, the concession ladder and every accept / counter / walk-away decision are computed in ordinary code (src/guardrails.js). The AI only words the reply, never sees the floor, and everything it writes is re-checked before a buyer sees it. The price sent to PayPal comes from the stored deal, never from the browser.
How PayPal is central (Sandbox only)
PayPal is the source of truth, not just the last step.
- Payments run through Orders v2 (capture, or authorize then capture for services), with refunds, voids, idempotent requests, and webhooks verified through PayPal's signature API (checked live on the hosted copy).
- The seller console asks PayPal, by capture ID, whether the money really arrived ("PayPal confirms $... received") and flags mismatches. Every deal keeps a money trail of real PayPal order, capture and refund IDs,
debug_ids and verified webhook events. - A seller Copilot works through PayPal tools but can only propose a refund or capture; nothing moves until the seller presses Confirm.
- PayPal's remote MCP server connects and lists 46 tools.
list_transactionsandlist_disputesran over MCP through the app's tool layer, and the hosted Copilot's transactions lookup shows themcptransport on screen. Money-moving actions never go through MCP, and the app falls back to the REST API if MCP stops executing.
What we did not verify live (so we do not claim it): a buyer paying a PayPal invoice and PayPal's real invoice-paid webhook (invoice create / send / cancel were run live); shipment tracking (built from PayPal's spec and tested against stubs and the simulated PayPal); the Copilot's propose a refund path on the live hosted model (it sometimes ends with "I could not finish that"; covered by unit tests, and the Deals table has a plain Refund button). Venmo and PayPal's early-access Agentic Commerce services are not used. Buyer sign-in is a demo (the code is shown on screen). Sandbox only: no real money moves.
How we built it
Node.js 20+ with zero npm dependencies on the server (node:test for tests); React 19, Vite, TypeScript and Tailwind for the front end, with AG Grid powering the deals table. AI wording comes from Gemini, Groq or any OpenAI-compatible model, with retries, a circuit breaker and an offline fallback so the demo never stops. AI tools used: Claude Code (development, tests, review), PayPal's developer docs, MCP server and Claude Code plugin, and at runtime Gemini and Groq models for the negotiation wording.
Proof it holds
- 206 unit tests with no dependencies, including a sweep showing no offer below the floor is ever accepted.
npm run eval: 500 hostile negotiations against a deliberately hostile AI (it over-concedes, leaks, invents prices, returns junk): 0 violations, plus 195 off-topic messages of which 0 reached the model.- 33 browser flows and an accessibility audit.
- An optional AI injection check that can only add flags, never clear one.
Challenges
Making a language model sound like five distinct personalities without ever letting it move a price; keeping free-tier rate limits from breaking the demo (automatic fallback, always labelled); and being exact about what was verified live versus simulated.
What's next
Verify shipment tracking and invoice payment against the live Sandbox, make the Copilot's refund proposals reliable on live models, real buyer authentication, per-seller accounts, and a hosted multi-tenant version.
Built during the submission period
HaggleBot was started for this hackathon. The public repository's history was condensed before publishing; see the README section "Built during the submission period".
Try it
Fastest: git clone https://github.com/BHUVANHEBBAR/haggle-bot.git, node src/server.js, then open http://localhost:3000/app/ (no install and no keys; demo mode uses a simulated PayPal and an offline AI). The full guide is JUDGES.md in the repository. A hosted copy using the real PayPal Sandbox is at https://haggle-bot.onrender.com/app/ (the free host can take 30-60 seconds to wake up).
Built With
- ag-grid
- gemini
- groq
- javascript
- mcp
- node.js
- paypal
- paypal-sandbox
- react
- render
- tailwindcss
- typescript
- vite