Inspiration
If you freelance, you know the feeling: the work is done, the invoice is sent, and the money still isn't there. 56% of US small businesses are owed money on unpaid invoices, around $17,500 each (QuickBooks, 2025). The chasing is awkward, but the waiting is worse, because you can't answer simple questions like "can I buy a new laptop next week, or will rent be a problem?"
Lots of tools send reminders. I wanted something that covers the whole money side of a small business, built on PayPal because that's where so many freelancers already send invoices: get paid, plan ahead, and grow. One rule from day one: the AI can suggest anything, but nothing reaches PayPal or a client until the owner clicks Approve.
What it does
You type "Bill Marcus for 3 logo concepts at $150 each plus a $60 rush fee" (or drop in a screenshot of the client's message) and PayPilot drafts a real PayPal invoice. Marcus has paid about two weeks late before, so it adds a 50% deposit and tells you why.
Unpaid invoices go on Autopilot: a friendly reminder, then a firm one, then a final one with an optional late fee, each written for that client and each waiting for your approval. There's also pay-to-unlock for final files, early-pay discounts, numbered receipts, and a page that shows exactly what your client sees.
The part I care about most comes after that:
- Can I afford this? The Budget Estimator runs 4,000 possible futures based on how each of your clients actually pays, and tells you the chance you can buy something on a given day without dropping below your safety cushion, how much you could safely spend, and which invoice the answer depends on.
- Where should I grow? The Growth page reads your invoice history: which clients are your champions and who's slipping away, which industries pay best and fastest, how concentrated your income is, your days sales outstanding, which clients should be on a retainer, and a 90-day plan written from those numbers.
- Business mode. A registered business describes what it sells in one sentence, and PayPilot builds its own categories, invoice lines and wording from it.
Anyone can try it: every visitor to the live demo gets a private copy and can connect their own PayPal sandbox or load demo data.
How I built it
The backend is Node.js 22 with Express 5 and SQLite (node:sqlite), with Server-Sent Events for live updates. The AI is Google Gemini through the @google/genai SDK, using tool calling across 13 tools. I split them into read tools (client insights, cash-flow forecast, budget check, growth insights and so on) and proposal tools (invoice, reminder, late fee, cancel). A proposal never runs by itself; it goes into a queue, and only the owner's click executes it.
On the PayPal side it uses Invoicing v2 (create with deposits and per-line tax, send, remind, update, record payment, cancel, import), webhooks checked with verify-webhook-signature, and OAuth 2.0, all in the sandbox. Every write sends a PayPal-Request-Id, so a retried request can't create a second invoice.
The Budget Estimator is ordinary statistics in code, not the model. For a purchase on day \(D\), with \(N = 4000\) simulated futures:
$$P(\text{safe}) = \frac{1}{N}\sum_{i=1}^{N} \mathbf{1}\left[\min_{D \le t \le D+30} B_i(t) \ge \text{cushion}\right]$$
Here \(B_i(t)\) is your balance on day \(t\) in future \(i\). Each unpaid invoice gets a payment delay sampled from that client's history, mixed with everyone else's history with weight \(w = \frac{n}{n+3}\) when the client has only a few invoices, and never earlier than today. Each payment arrives after PayPal's fee and your tax set-aside, \((a - 0.0349a - 0.49)(1 - \tau)\), and the result is shown with its error margin, \(1.96\sqrt{p(1-p)/N}\), which is about ±1.3 points.
For the public demo, AsyncLocalStorage carries a per-visitor workspace through every request, each with its own SQLite file. 129 tests run in GitHub Actions, and every push to main deploys to Azure App Service.
Challenges I ran into
Early on I realised that if the model is allowed to produce numbers, it can state a payment date or a risk level with nothing behind it. So I moved every figure (risk, forecasts, the budget answer, growth metrics) into code, and the model only gets tool results to explain.
Some Gemini calls took 35 to 55 seconds, which is far too slow for a setup screen. Lighter models now go first with a 9-second limit and a rule-based fallback, and the AI's version replaces it in the background when it's ready.
The budget answer used to wobble: a small change to the inputs could move the chance a few points either way, just from randomness. Running every input against the same 4,000 futures (common random numbers) fixed that, and there are tests checking that a higher price never gives a higher chance.
Putting it online for judges meant one shared database was out of the question, since one person's keys and invoices would be visible to the next. That's why every visitor gets a private workspace, with rate limits and automatic cleanup after three days.
And some things were just sandbox reality: my sandbox account is based in India, where PayPal's partial payments aren't available, so deposits fall back to a clear note on the invoice.
Accomplishments that I'm proud of
It's a working product, not a mockup. It creates real sandbox invoices, verifies real webhooks, and runs live where anyone can test it with their own keys. The approval rule is enforced in code, not just promised in the UI. And it goes past reminders into planning and growth, with numbers that come from the owner's own data.
What I learned
How to give an AI agent tools without giving it the keys to everything, how to make a probability stable enough to test, and how much careful engineering "simple" money features need: idempotent writes, webhook checks, rounding to the cent. I also learned a lot about deploying and securing a multi-user app on Azure.
What's next
Live PayPal accounts instead of sandbox, reminders over WhatsApp and SMS, multi-currency books, an export for accountants, and exposing PayPilot's tools over MCP so other agents can use them.
Built With
- ai-agents
- azure
- azure-app-service
- css3
- express.js
- gemini
- github-actions
- google-gemini-api
- google-genai
- html5
- javascript
- monte-carlo
- node.js
- oauth2
- paypal
- paypal-invoicing-api
- paypal-sandbox
- paypal-webhooks
- server-sent-events
- sqlite
- tool-calling