Inspiration
Freelancers and small studios do two unpaid jobs after the real work: turning cryptic timesheet notes ("fixed nav", "call w/ team", "stuff") into an invoice a client will approve, and chasing that invoice when it is late. Both are awkward, both are slow, and both leak money: in Intuit's 2025 QuickBooks Small Business Late Payments Report, 56% of the US small businesses surveyed said they were owed money from unpaid invoices, about $17,500 on average. AI is good at the wording and the chasing, but nobody wants a model deciding how many hours to bill. Logbill splits the work along that line.
What it does
- Import a timesheet CSV from Toggl, Clockify, Harvest or a Jira worklog export.
- AI drafts the invoice lines. Claude Haiku 5.5 groups the entries into a few client-ready lines, writes them in plain language, and suggests what to leave off (internal admin, personal time, another client's work, learning), with a reason for each. It also flags entries worth a second look.
- The code does the maths. Logbill computes hours, rates and money itself (hours to two decimals, as PayPal multiplies them), splits lines so no line mixes hourly rates, catches exact duplicates and 10-hour-plus days without AI, places anything the model missed on the closest line, and proves every entry is billed exactly once or left off with a reason.
- Check it in AG Grid. Edit wording and rates, move any entry to another line, a new line or off the invoice, and watch the totals recompute.
- Send with PayPal. One click creates and sends the invoice with PayPal's Invoicing API, with a pay link and a QR code. The client pays on PayPal's invoice page by PayPal, Venmo, Pay Later or card.
- Collect. The dashboard follows PayPal's statuses live. The collections agent, built on the PayPal Agent Toolkit, searches the unpaid invoices, checks which reminders already went out, reads each invoice, and drafts a friendly, firm or final reminder depending on how late it is. You approve each one, or switch on autopilot and it sends them itself through the Toolkit's
send_invoice_reminder, but only when Logbill's rules allow: nothing before the due date (bar a heads-up two days out), at most one reminder every three days and three in total, never a new recipient, never a cancellation.
How we built it
- PayPal: REST Invoicing v2 for create, send, search (by a per-workspace
reference), get, remind, cancel and QR codes; the PayPal Agent Toolkit (@paypal/agent-toolkit, OpenAI tool format) for the agent'ssearch_invoicing,get_invoiceandsend_invoice_reminder; and the Webhooks API: Logbill registers its own webhook for invoice paid, cancelled, refunded and updated events, verifies each delivery's SHA256withRSA signature with PayPal's certificate, and pushes the event to that workspace's dashboard, so a payment appears seconds after the client pays. All in the sandbox. - AI: Claude Haiku 5.5 through OpenRouter's OpenAI-compatible API. Drafting forces a
submit_drafttool call, validates it with Zod, and gives the model one correction round with the exact rule it broke (for example, a line mixing two hourly rates). The agent is a tool-calling loop over the Toolkit's tools and three of Logbill's own (reminder_history,propose_reminder,propose_no_action). A draft costs about $0.002 and an agent run about $0.006. - AG Grid Community 34: a timesheet grid with an in-cell select to move entries between lines, an editable invoice-lines grid (wrapped text, popup editor, pinned totals row, flashing amounts), and an invoices grid (status chips, overdue colouring, quick filter, pinned actions, tooltips, live refresh).
- App: TypeScript end to end: React 18 and Vite, Express 5, a shared
core.tsused by both sides, 18 Vitest tests, hosted on AWS (EC2 with Caddy for HTTPS, secrets in SSM Parameter Store).
Challenges we ran into
- Models are confident and occasionally wrong about grouping: they mixed rates on one line or skipped a vague "stuff" entry. Instead of trusting the prompt, Logbill measures the draft against the timesheet, asks for one correction with the exact problem, and then repairs whatever is left deterministically, so the numbers can never drift.
- An agent that can send email on its own needs hard limits. The rules live in code that runs before every send, and a blocked send goes back to the model as a tool error with the reason, so it adapts instead of retrying.
- Many visitors share one sandbox merchant in the hosted demo, so every invoice carries the browser's workspace id as its PayPal
reference, and the server checks it before reading, reminding or cancelling.
Accomplishments that we're proud of
The whole loop works for real in the sandbox: a 35-entry timesheet becomes a correct $8,805.00 invoice, a test buyer pays it on PayPal's page, Logbill shows it paid within seconds through PayPal's webhook, and the agent chases three older invoices in three different tones, all in about two minutes.
What we learned
The best split between AI and code is "AI for words and judgement, code for numbers and rules". PayPal's Agent Toolkit made the agent's PayPal side tiny; the effort went into the guardrails around it.
What's next for Logbill
Pull time straight from the Toggl, Clockify, Harvest and Jira APIs; recurring retainers with PayPal's recurring invoices; partial payments and deposits; and letting the agent offer a payment plan when a client is struggling.
Built With
- ag-grid
- amazon-ec2
- caddy
- claude
- express.js
- node.js
- openrouter
- paypal
- paypal-agent-toolkit
- react
- typescript
- vite
- vitest
- zod