-
-
Morning brief from live PayPal sandbox data: three overdue invoices totalling $4,000 and one open dispute, each linked to its records.
-
Every highlight links to its records: "Show in grid" opens AG Grid with Maya Chen's invoice 0007 highlighted.
-
The copilot works the grid: asked for overdue invoices, largest first, it filters and sorts AG Grid to the three records.
-
Nothing changes without approval: the reminder for invoice 0007 waits on a card with the exact subject and note to be sent.
-
After approval, PayPal accepts the reminder for invoice 0007 and the copilot confirms it in one line.
-
PayPal's rules, checked first: invoice 0002 is partially paid, so cancelling stays disabled and PayPal is never called.
-
Invoice 0007 details: balance, payment summary, dates and PayPal status, one click from the copilot or a draft reminder.
Inspiration
Small merchants run their business out of the PayPal dashboard, a spreadsheet, and memory. Overdue invoices, disputes with a response deadline, refunds, and fees all live in different tabs, and nothing tells you what matters most this morning. We wanted one screen where a merchant can see everything at once and tell an assistant what to do about it in plain words, without ever worrying that the assistant will move money on its own.
What it does
Ledgerly is a live dashboard plus a copilot that works it with you.
- Four live views from the PayPal REST APIs: transactions, invoices, disputes, and catalog with billing plans, rendered in AG Grid with sorting, filtering, quick search, and multi-row selection.
- A morning brief. On open, the model reads a compact snapshot of the account and lists the handful of things that need attention today, ranked by severity, each with a "Show in grid" link that jumps to the exact rows and a prefilled prompt.
- A copilot wired to the PayPal Agent Toolkit. Ask "who owes me money" or "summarize the last 30 days and the fees I paid" and it reads the data. Tell it "send reminders to everyone more than 14 days overdue" and it acts on the account: reminders, invoices, and payments, as shown in the demo. Accepting a dispute claim goes through the same card; we tested it end to end on a sandbox dispute. The toolkit's other write tools (refunds, subscriptions) are available behind it too.
- Approval on every write. Ledgerly enables 27 of the toolkit's 47 tools. The 12 that change something in PayPal pause for an approval card in the chat that states who, what, and how much; the 15 read-only tools run freely, so the copilot can investigate before it proposes. The gate is a rule, not a list, so a toolkit tool enabled later is gated unless it is read-only.
- The copilot drives the grid. Two browser-side tools let it switch views, apply filters and sorts, and flash the rows it is talking about, and read back what is on screen after your own filters. "Show me invoices over $500" produces a filtered grid, not a paragraph.
It also notices things. During testing, asked about a selected catalog row, the copilot pointed out that the catalog contained duplicate products with duplicate $1,500 plans, then said honestly that its tools could not delete them.
How we built it
Next.js 16 with the App Router serves both the UI and the API routes. The chat route streams through the Vercel AI SDK with streamText, a multi-step tool loop, and the SDK's tool-approval mechanism for gated tools. The PayPal Agent Toolkit provides the account tools; we wrote a small adapter because the toolkit ships tools in the AI SDK v4 format and the app runs on v7. Instead of a hand-picked list of risky tools, the adapter gates every tool whose name is not read-only, so a toolkit upgrade is safe by default.
The grid views call PayPal's Transaction Search, Invoicing v2, Customer Disputes, and Catalog APIs directly through the toolkit's OAuth client. AG Grid Community renders the data with a custom "ledger paper" theme and exposes its API to the copilot. The brief uses structured output against a zod schema. The copilot is not tied to one model: a single file selects the provider and model from environment variables. The demo runs Gemini 3.1 Pro. A seed script populates a fresh sandbox with products, a plan, invoices in several states, and card payments. The whole thing is one Render web service deployed from a blueprint.
Challenges we ran into
- The toolkit targets an older AI SDK, so tool schemas and results had to be bridged and verified at runtime.
- In toolkit 1.11.0,
accept_dispute_claimchecks itsnoteagainst the dispute-ID pattern, so any note with a space was rejected before reaching PayPal. Our adapter replaces that one schema. - Test disputes take extra setup in the sandbox (an API scope granted by PayPal, or a buyer claim filed by hand in the Resolution Center), and Transaction Search can take up to three hours to show new payments, so the demo data was designed around what we could produce in time.
- Making the model point at specific grid rows reliably required teaching it the grid's column semantics and giving it a snapshot tool, rather than letting it guess at row ids.
- A denylist of "dangerous" tools kept missing cases. Switching to an allowlist of read-only tools fixed the class of bug instead of one instance.
Accomplishments that we're proud of
- Approval-gated actions that feel safe enough to hand to a real merchant: nothing changes in PayPal without a click.
- A copilot that manipulates the UI it lives in, so answers are visible in the data rather than described.
- A brief that reads live sandbox data and gets the numbers right, overdue totals and days late included.
- One deployable: UI, API, and agent loop in a single Render service with a health check.
What we learned
Agent tooling is only as good as the guardrails around it. The approval gate and the "show me" tools did more for trust than any prompt engineering. We also learned that the model will happily describe capabilities it does not have unless the prompt and the tools agree on what is possible.
What's next for Ledgerly
Extend rich invoice approval previews to refunds and other actions that still use a generic parameter list.
Scheduled briefs delivered by email, dispute evidence drafting from order history, batch approvals so one click covers a set of reminders, and multi-account support for bookkeepers who manage several merchants.
Built With
- ag-grid
- gemini
- google-ai-studio
- next.js
- paypal
- paypal-agent-toolkit
- paypal-rest-api
- react
- render
- tailwind
- typescript
- vercel-ai-sdk