Inspiration
Most online prices look fixed, but plenty of sellers have room to move on price, deposit and delivery time. Small businesses that buy supplies from several suppliers rarely have time to compare offers, let alone haggle. Suppliers have the opposite problem: they cannot answer every inquiry. Today's shopping agents search and compare. None of them negotiate, and none treat payment terms as part of the deal. We wanted to see what happens when an AI agent negotiates on your behalf and PayPal settles whatever it agrees.
What it does
- Mandate. The buyer picks a product from a catalog of ten (or adds a custom product), then sets a maximum budget and a target price. This is a hard limit the agent cannot exceed.
- Parallel negotiation. The buyer agent negotiates with several seller agents at once over price, deposit percentage and delivery days. It only quotes competing prices that another seller really offered.
- Ranking. A scoring function ranks the final offers, accounting for price, the cost of the deposit and delivery time. The best offer wins.
- PayPal settlement. The full amount is authorized, the negotiated deposit is captured right away, and the balance is captured when the buyer confirms delivery.
- Seller shops, no code. A merchant adds a shop with a short form, or types rules such as "never go below 80% of list, I like a 30% deposit, I can ship in 3 days". Plain English is compiled into a structured seller policy by an AI model. Either way the shop becomes a live seller agent that competes in the same market.
- Editable market. The list and lowest price of each default seller can be changed for any product, so a custom shop is always compared fairly.
- Trading Floor. The negotiation is shown live: one lane per seller with its current price and chat messages, a price-by-round chart, and a live offers table (AG Grid). A running negotiation keeps going if you browse to another page and come back.
- Private by default. Each browser gets a signed anonymous identity, and a deal can only be read, paid or delivered by the browser that created it.
How we built it
Backend: FastAPI. A negotiation orchestrator runs the buyer and sellers in parallel and streams every event to the browser with server-sent events. AI: Google Gemini (free tier), with automatic fallback across Flash-Lite models. Models write the offers and messages and compile plain-English seller rules into a policy. Code makes the decisions that matter. A seller offer below its floor is rejected and corrected. A buyer acceptance above the budget, or above the target while rounds remain, is blocked. A seller cannot promise a delivery time it cannot meet. Messages that quote a competing price that was never offered are rewritten. PayPal (sandbox): Orders API v2 with the AUTHORIZE intent, one payee account per seller, and partial captures for the deposit and the balance. The server stores the winning deal, so a browser can never send a fake price to PayPal, and the return from PayPal carries a signed value that proves which browser started the order. Frontend: Next.js and Tailwind, exported as static files and served by the same FastAPI service. AG Grid Community powers the live offers log and the benchmark table. Hosting: Render (free tier), with a recorded-negotiation fallback so the demo still works if the AI service is busy.
Challenges we ran into
Language models are happy to invent leverage ("another seller offered $85") and to accept a deal too early. We moved every decision into code and rewrite any message that quotes a price nobody offered. Free-tier rate limits and overloaded models made live negotiations slow. We added concurrency limits, a model fallback chain, and a recorded negotiation the app switches to (and says so) when live models fail. PayPal sandbox accounts created in India cannot make domestic payments, so all test accounts use the United States. Keeping deals on the server, not in the browser, so the price PayPal receives is always the negotiated price, and making sure only the browser that started a deal can pay for it. Keeping a streaming negotiation alive while the user moves between pages.
Accomplishments that we're proud of
A working end-to-end flow: request, parallel negotiation, ranked offers, PayPal deposit and balance. A no-code seller console that turns a short form or plain English into an agent that competes live. Agents that cannot break the buyer's budget or a seller's floor, verified across the benchmark runs.
What we learned
Agents that touch money need hard guardrails in code. The model is best used for language and judgement within limits, not for the limits themselves.
What's next for Haggle
Let real merchants connect their own PayPal accounts and policies, with saved and editable shops. Negotiate more terms, such as net-days payment through PayPal invoicing and bulk-order discounts. Dispute handling: if delivery is rejected, the deposit and balance logic follows the agreed terms. Seller reputation scores that carry across negotiations.
Built With
- ag-grid
- fastapi
- gemini
- google-gemini-api
- nextjs
- paypal
- paypal-orders-api
- python
- react
- render
- tailwindcss
- typescript