Inspiration
Small businesses lose hours turning a messy customer email into a priced quote, then an invoice, then chasing payment. PayPal handles the payment, but the work before the invoice is still manual. I wanted to close that gap without handing money decisions to an AI.
What it does
QuoteLoop is a quote-to-cash agent built on the PayPal Invoicing API.
- Paste a customer's email or chat message.
- Extract: an LLM reads it and returns structured fields (customer, items, quantities, deadline, discount asked).
- Price: a deterministic rules engine builds the quote (volume tiers, rush surcharge, a hard discount cap) and flags anything outside policy.
- Approve: the owner reviews, adjusts or counters, then approves. Nothing reaches PayPal before that.
- Invoice: a real PayPal invoice is created and sent.
- Track: the status updates live (Drafted, Sent, Paid) through PayPal webhooks, with a polling fallback.
- Follow up: the owner pastes the customer's reply. The agent classifies it, checks it against the pricing rules, drafts an answer, and can prepare a revised quote. Sending it creates a new invoice and cancels the old one through PayPal.
The core principle: AI proposes, rules decide, a human approves. The model never does money math.
How I built it
- Backend: Python, FastAPI, SQLite.
- PayPal: Invoicing API (generate number, create, send, get, remind, cancel), OAuth2 client credentials, and webhooks with signature verification via PayPal's verify endpoint.
- AI: Groq (
openai/gpt-oss-20b) in JSON mode to extract requests and classify and draft customer replies, with one retry on bad JSON. - Pricing: a plain-Python engine using
Decimal, driven by a singlepricing.json. - UI: a single-page vanilla JS app with an AG Grid invoice ledger (search, floating filters, live status, totals row).
- Hosting: Render. The app is covered by 24 automated tests (pricing, flow, extraction, follow-up).
Challenges
- PayPal specifics:
NET_14isn't a valid payment term, so I switched toNET_15. India-based sandbox buyers are blocked for USD invoices (INR_FOREIGN_CURRENCY_BLOCKED), so I used a US sandbox buyer. - Trusting the model: early on the LLM's numbers couldn't be trusted, so all pricing moved into code and the model only fills structured fields.
- No inbound email in PayPal: replies can't be read automatically, so the follow-up agent works on pasted replies and keeps a human in the loop.
- Reliability: webhooks can be slow or missed, so a polling fallback checks PayPal every few seconds after sending.
- Revisions: replacing an invoice safely means creating the new one first, then cancelling the old one. A failed cancel is reported, not fatal.
What I learned
Treat the LLM as a reader and writer, not a calculator. Put policy in code, keep a human on every send, and handle PayPal's real-world edge cases (terms, currencies, webhook verification).
What's next
Inbound email parsing, multi-currency and tax rules, learning price rules from past invoices, and Slack approvals.