Inspiration

Freelancers and small businesses rarely struggle to send invoices. They struggle to get paid on time. Chasing a client is awkward, repetitive, and easy to put off, and cash flow suffers for it. As an aspiring data analyst, I wanted to see whether an AI agent could do the chasing and the number-crunching while the owner stays in control of every decision that touches money.

What it does

PayPilot connects to PayPal Invoicing (sandbox) and acts as an accounts-receivable assistant:

  • Ask the agent anything. "Who owes me money?" or "Which client is the biggest risk?" The agent calls tools that read live PayPal invoice data.
  • Morning review. One click, and the agent goes through every overdue invoice, picks a tone (friendly, firm, or final notice) based on days overdue and client risk, and writes a specific reminder.
  • Human approval for every action. The agent can only propose reminders and new invoices. Each proposal shows the exact message, the agent's reasoning, and a payment link with a QR code. Nothing reaches PayPal until the owner clicks Approve.
  • Client risk scores. Calculated from each client's real payment history: average days late, share of late payments, and what they currently owe.
  • 30-day cash forecast. Open invoices are projected to land after each client's usual delay and weighted by risk, compared against "everyone pays on time".
  • AG Grid invoice table and an audit log of every proposal, approval, rejection, and failure.

How I built it

Built solo with Next.js and TypeScript. The PayPal Invoicing API v2 (sandbox) handles listing invoices, creating and sending invoices, and sending payment reminders. The agent runs on Gemini function calling with two kinds of tools: read tools (list invoices, client risk, cash forecast, payment link) that run immediately, and propose tools (reminder, new invoice) that only add an item to an approval queue. The only code path that calls PayPal's remind and send endpoints is the approval button. The invoice table uses AG Grid, and the app is hosted on Render.

Challenges

  • PayPal permissions. Every Invoicing call returned a 403 until the sandbox app had the Invoicing feature enabled. I wrote a small diagnostic script that reads the scopes in the access token to prove it.
  • Moving AI models. During the build, Gemini model names were retired for new users and others were overloaded or stalling. I added timeouts, retries with backoff, and model fallbacks so the agent degrades gracefully instead of hanging.
  • Trust. I wanted the agent to be useful without being dangerous, so the separation between "propose" and "execute" is structural, not just a prompt instruction.
  • Realistic demo data. Risk scores need payment history, so I wrote a seed script that creates back-dated invoices and recorded payments with different client behaviours.

What I learned

How to design an agent around human approval, how PayPal's sandbox permissions and Invoicing flow work, and that anything built on fast-moving AI models needs defensive code around the model call.

What's next

Dispute triage, multi-currency support, learning each client's best reminder timing, and user login. PayPilot currently runs against the PayPal sandbox only.

Built With

Share this project:

Updates

Submission history