Inspiration

Freelancers often say the hardest part of the job isn't the work, it's getting paid. Writing invoices, tracking who has paid, and sending awkward follow-up emails take hours every month, and late payments make cash flow unpredictable. I wanted to see what happens when an AI agent takes over that second job, while the freelancer stays in control of every message that goes out.

What it does

Unlike invoice generators, InvoicePilot covers the whole getting-paid lifecycle: it drafts invoices, chases late payers with escalating reminders through PayPal's reminder API, and learns which clients pay late, all with a human approving every action.

  • Natural-language invoicing. Type "Bill Acme Corp $1,200 for logo design, due in 14 days" and the agent creates a real PayPal draft invoice, working out the client, line items and due date. If something is missing or unclear, it asks instead of guessing. The AI can only draft: nothing is sent until you review it and click Approve & Send.
  • AI late-payment chaser. The Follow-ups page lists every overdue PayPal invoice, color-coded by urgency. One click drafts a reminder for each, with a tone that escalates from friendly (a few days late) to firm but courteous (30+ days late). You can edit any message before sending it through PayPal's reminder API.
  • Cash-flow dashboard. Built with AG Grid: KPI cards, a filterable invoice grid with live totals, overdue highlighting and CSV export, and a per-client reliability rating calculated from real payment history. Generate insights turns the numbers into specific actions, like which client to follow up with today.

How I built it

  • Next.js (App Router, TypeScript), deployed on Render.
  • Google Gemini with function calling powers the agent. The model calls a create_draft_invoice tool, and the server validates every call before touching PayPal: the client must exist, amounts must be positive, the due date can't be in the past, and only one draft is created per message. Gemini also returns structured JSON for the reminder drafts and dashboard insights.
  • PayPal Invoicing API v2 (sandbox): OAuth, creating, sending, listing and fetching invoices, sending reminders, and recording payments.
  • AG Grid Community for the invoice and client grids, with custom cell renderers, filters, status chips, a pinned totals row that updates with filtering, and light and dark themes.

Challenges I ran into

  • Speed and reliability. My first version took up to 4 minutes per request: the newest Gemini model was overloaded, calls had no timeout, and each request made three model calls. I added timeouts, retries with model fallback, minimal "thinking" settings, and redesigned the flow so a typical request needs a single model call. That brought it down to a few seconds.
  • Regional restrictions. PayPal blocks invoices to recipients within India, where I'm based, so I set up a US sandbox customer account and documented this in the README for anyone running the project.
  • Realistic demo data. To demo the chaser and dashboard honestly, I wrote seed scripts that create real sandbox invoices with past due dates and recorded payments.

Accomplishments that I'm proud of

  • A complete, working product that runs end to end on real PayPal sandbox data, not a mockup, with a live hosted demo.
  • Human-in-the-loop by design: the AI drafts, the human decides.
  • Privacy-conscious AI use: client emails are stripped before any data reaches the model, and reliability ratings are computed in code rather than guessed by AI.
  • Production-minded touches: rate limiting, model fallback, and graceful error handling.

What I learned

Building an agent is less about the AI call itself and more about the guardrails around it: validating tool calls, handling failures gracefully, and keeping latency low enough that the product feels instant.

What's next for InvoicePilot

User accounts and authentication, importing real client lists, automatic reminder scheduling, support for multiple currencies, and moving from the PayPal sandbox to live accounts.

Built With

Share this project:

Updates

Submission history