๐Ÿ’ก Inspiration

Online stores lose nearly 70% of shopping carts before checkout, with price friction being the #1 driver. In the physical world, a skilled salesperson can save a sale by offering a timely student discount, a first-time buyer deal, or an instant-payment incentive while still protecting the store's profit margins. Static e-commerce pages can't do thatโ€”so we built HaggleBot to bring autonomous Agentic Commerce to PayPal Checkout.

๐Ÿš€ What it does

HaggleBot transforms static product pages into live, margin-aware negotiations that dynamically mint custom-priced PayPal Sandbox Orders on the spot:

  • Merchant Profit Guardrails: Merchants configure a public list_price alongside a confidential minimum floor_price and maximum negotiation rounds.
  • Autonomous Negotiation Engine: Shoppers negotiate in natural language (or via quick-offer buttons) while tracking real-time negotiation progress, best offers, and counter-offers.
  • Dynamic PayPal Order Minting: The moment both buyer and AI agent agree on a price, HaggleBot automatically invokes the PayPal Orders V2 REST API (/v2/checkout/orders) to generate a live, tamper-proof PayPal checkout link for the exact negotiated amount.
  • Live Payment Verification: Once the buyer approves the payment in the PayPal Sandbox, HaggleBot queries /v2/checkout/orders/{id} to verify payment completion in real time.

๐Ÿ› ๏ธ How we built it

  • Frontend & State Management: Built with Python and Streamlit, featuring a clean split-pane layout with a live negotiation progress tracker (Round X of 6), quick-offer triggers, and an interactive chat interface.
  • AI & Deterministic Guardrails: Powered by Google Gemini (google-genai) using Pydantic structured JSON outputs (deal_reached, agreed_price, discount_reason) combined with a strict Python-level price floor clamp so the AI can never be prompt-injected into selling below cost.
  • PayPal Integration: Integrated directly with the PayPal REST API Sandbox using OAuth 2.0 client credentials (/v1/oauth2/token) and the PayPal Orders V2 API (/v2/checkout/orders) to dynamically create custom-priced CAPTURE orders and verify order status.

๐Ÿšง Challenges we ran into

  • Preventing Prompt Injection on Pricing: Early on, clever buyers could try to trick the LLM into offering a $1 price. We solved this with a dual-layer defense: strict system instructions paired with a deterministic Python guardrail (max(agreed_price, floor_price)) before calling the PayPal API.
  • Seamless Handoff from Chat to Checkout: Ensuring the transition from conversational state to a live PayPal transaction felt instantaneous required structuring the LLM output as strict JSON so the PayPal API triggers automatically on the exact turn a deal is reached.

๐Ÿ† Accomplishments that we're proud of

  • Building an end-to-end Agentic Commerce workflow where an AI agent doesn't just chatโ€”it autonomously executes financial API calls via PayPal to close a sale.
  • Designing an intuitive UI that shows both the shopper's best offer and the bot's current price alongside a single-click PayPal Sandbox checkout card.

๐Ÿ“š What we learned

  • How to authenticate and orchestrate the PayPal Orders V2 API dynamically from a Python backend.
  • How combining structured LLM outputs with deterministic financial guardrails enables safe, autonomous AI commerce.

๐Ÿ”ฎ What's next for HaggleBot: AI Deal-Maker & PayPal Checkout

  • Multi-Item Bundle Negotiations: Letting shoppers negotiate discounts across entire carts (e.g., "I'll buy both the keyboard and headphones right now for $450").
  • PayPal Webhooks & Invoicing API: Adding automated webhook listeners for instant fulfillment and B2B quote-to-invoice generation via the PayPal Invoicing API.

Built With

Share this project:

Updates

Submission history