Inspiration

I kept hearing the same story from freelancers: you finish the work, send the invoice, and then wait. Sometimes weeks. Meanwhile your own bills don't wait.

Every invoicing tool I looked at only helps after the invoice is already late, with reminders, nudges and awkward follow-ups. I wondered what would happen if the tool saw it coming. If a client has paid late three times out of four, why send them the same invoice as everyone else?

What it does

OnTime is an invoicing assistant that tries to stop late payments before they happen.

You paste a client's email. Gemini reads it and fills in the invoice, so there's no typing. Then OnTime checks how that client has paid in the past and gives them a risk score with plain reasons, like "paid late on 3 of the last 4 invoices."

If the client looks risky, OnTime changes the terms to protect you. Safe clients get normal terms. New clients get shorter terms with a small early-pay discount. Risky clients get a 40% deposit up front and the rest on delivery.

You approve, and a real invoice goes out through the PayPal Invoicing API (sandbox). After that, an AI agent keeps an eye on the invoice and writes reminders, starting friendly and getting firmer as it gets later.

The important part is that the agent can't go rogue. Friendly reminders send automatically. Firm or formal ones are stopped by a guard in code and wait in a queue until I approve them. Everything it does is written to a plain-English audit log.

How we built it

I built it solo with Next.js, TypeScript, Tailwind and shadcn/ui, with SQLite for storage.

  • PayPal: the Invoicing API in the free sandbox. OnTime creates and sends invoices, sends reminders, reads invoice status and records payments. For high-risk clients, the deposit and balance are two linked invoices.
  • Gemini: Gemini 3.8 Flash handles three jobs: turning emails into structured invoice data, explaining the recommended terms in plain language, and running the follow-up agent, which uses function calling to decide what to send.
  • Plain code for the serious parts: the risk score, the payment terms and every dollar amount are calculated in code. The AI never does the math, and it never decides what it's allowed to do. ## Challenges we ran into
  • Keeping the AI inside the lines. I didn't want to rely on a prompt saying "please don't send rude messages." So the rules run in code before every action. In the demo, the agent decides a firm message is needed, tries to send it, and gets blocked. That moment convinced me the design works.
  • Free-tier limits and timeouts. Gemini hit a daily quota and one call timed out mid-demo. Instead of hiding it, I added a response cache, longer timeouts, a rule-based fallback, and a label on every AI output showing where it came from.
  • A bug that told a small lie. At one point the app could record a payment on its own side while the PayPal invoice stayed unpaid. Catching that taught me to treat the audit log as something that must always tell the truth, so now every action uses the provider that created the invoice, and failed sends are shown as failed.
  • Learning PayPal one call at a time. I tested creating, sending, reminding and recording payments separately before building anything on top of them.

Accomplishments that we're proud of

  • A full flow that works end to end: email in, risk-checked invoice out, delivered to a client's PayPal account, with an agent following up afterward.
  • Seeing the guard stop the AI in real time, with the exact rule named in plain English.
  • Every AI output carries a label (live, cache or fallback), so nothing pretends to be something it isn't.

What we learned

Putting AI near money is mostly a trust problem. Clever prompts matter less than guardrails, approvals and a log you can read. I also learned that being honest about what's simulated and what's real makes a demo stronger, not weaker.

To be clear about the demo: the clock (the "jump ahead" buttons) and the client's payment are simulated so weeks can be shown in seconds. The PayPal and Gemini calls are real.

What's next for OnTime: AI Invoicing Agent That Prevents Late Pay

  • Real PayPal webhooks, so OnTime learns when a client actually pays instead of me recording it.
  • A risk score that learns from every payment, so it gets smarter over time.
  • An editor for the rules, so freelancers can set their own limits.
  • A cash-flow view: "here's the money you can really count on this month."

Built With

Share this project:

Updates

Submission history