-
-
What the family sees: their application approved and paid to their PayPal account, step by step.
-
The fund at a glance: money raised, what has reached families, and the latest payouts, live.
-
The public ledger: every gift and every grant with its PayPal payout id, and no names.
-
Ask the ledger: staff ask in plain English, and the AI auditor answers from the data and adds the chart with AG Studio’s agents.
Inspiration
After a flood, neighbors raise money within days. Getting it to the right families is the slow part. Small relief funds often run on a personal payment app, a spreadsheet and a few volunteers who read every application by hand. That breaks under load. After the July 2025 Chantal floods in North Carolina, Triangle Mutual Aid hit its payment app's transfer caps, its donations were held, and volunteers spent days on the phone (Triangle Blog Blog). And fast money without a ledger loses trust: after the 2021 Texas freeze, other organizers questioned a fund that reported raising $2.6M with a spreadsheet that showed no backup for its numbers (VICE).
Fast, verified cash is possible at scale: in November 2025 GiveDirectly paid 238,153 households within one to two days of a missed SNAP deposit (GiveDirectly). A five-volunteer fund has no such stack. We wanted to give it an agent that does the routine work, while people keep every rejection and every larger grant.
What it does
AidRelay is an open-source AI case officer for small community relief funds: a nonprofit with a PayPal Business account, a handful of volunteers and no engineers. It runs on the fund's own PayPal account.
- Donations come in through PayPal and show on a public ledger within about ten seconds.
- Every application, submitted in English or Spanish, is checked against a policy the fund's volunteers write: was this photo, address or contact used before, and do the photos and the story fit the rules.
- Small, clear cases are approved and paid by the agent itself through PayPal Payouts, up to the fund's limit and only when a second, separate evaluation agrees. Every other case gets a follow-up question or goes to a volunteer, with the agent's reasons and the policy clause it relied on.
- The agent can approve, but it can never reject. Only a person can.
- When money runs short, approved families wait in order of need, and the next donation pays as many as it covers, with no staff action.
- Anyone can read the ledger. It lists every donation and every grant with its PayPal id and no names, plus the median time from application to payment. Staff can also ask it questions in plain English, and an AI auditor answers with data and charts.
Everything in the demo runs on the PayPal sandbox; no real money moves. The flood and the applications are fictional, applicant photos are AI-generated, and the $250 auto-pay limit is an example (each fund sets its own).
How we built it
- PayPal: Orders v2 (create and capture) for donations, Payouts v1 for grants, webhooks verified with
verify-webhook-signature, and the JS SDK donate button. The agent's PayPal tools are our own typed functions over the REST API. - Claude through the Vercel AI SDK: Claude Sonnet 5.5 runs the case officer's tool loop and returns a schema-validated decision on each case from the photos and the story. Claude Haiku 5.5 pre-screens photos, runs the ledger auditor and screens the questions put to it. The policy and system prompt are prompt-cached.
- Guardrails in code, not in the prompt: ten auto-approve conditions, amounts looked up from the policy (no tool accepts one from the model), hourly and daily limits re-checked inside the database transaction that claims a payout, a state machine for every status change, funds reserved before every payout, and one idempotent payout per case.
- AG Grid Enterprise and AG Studio: the staff queue (grouping by level of need with totals, flags, inline amount edits, bulk approval); the public ledger as an AG Studio report with two custom widgets and cross-filtering; and Ask the ledger, where our auditor agent hands chart work to AG Studio's built-in agents, all reaching Claude through our own
AgLlmAdapter. - Next.js 15, Firestore and Cloud Storage, deployed on Cloud Run. The agent is event-driven: it wakes on a new application, a captured donation, a volunteer's approval, or a scheduled check every 10 minutes.
- 377 automated tests cover the guardrails, payouts and retries, PayPal events, allocation, anonymization and the AG Studio bridge to Claude, with PayPal and the model mocked.
Challenges we ran into
- Letting an AI move money safely. We split every decision into what the model judges (eligibility, level of need, reasons) and what code decides (the amount, duplicates, limits, payment order, every status change). The model can change an amount only through the level of need it reports, and an unattended payout needs a second evaluation that agrees.
- Paying exactly once. PayPal's capture reply and its webhook can arrive in either order, webhooks are redelivered, and parallel agent runs can race. Reservations, one payout record per case and limit checks inside the transaction keep a family from being paid twice and the fund from overdrawing.
- Untrusted text. An applicant's story and the writing in their photos can try to instruct the model. Both are delimited as data and scanned, and a hit sends the case to a volunteer. Questions to the auditor are screened on the server, and off-topic ones or attempts to rewrite its instructions get a fixed reply.
- No Payouts tool in PayPal's Agent Toolkit when we started, so we built the payout path on the REST API ourselves.
- Connecting AG Studio's Agent Framework to Claude, including streaming its events and repairing the malformed tool arguments a fast model sometimes sends.
Accomplishments that we're proud of
- An agent that sends PayPal Payouts itself, end to end in the sandbox, while every rejection stays with a person.
- A donation that pays the families already waiting, with no staff action.
- A public ledger where every donation and every grant carries its PayPal id and no row carries a name, an address or a contact detail.
What we learned
The model is good at judgment and bad at being a ledger. The design that worked was to let the model judge and let code count. We also learned how much trust depends on what you show: the reasons, the policy clause, and the PayPal id next to every payment.
What's next for AidRelay
Evidence today is a photo and a story, not an identity check; the limits cap what a mistake can cost. Next: PayPal fees on the ledger, re-issuing payouts that fail after PayPal accepted them, PayPal's v6 JavaScript SDK, more languages for applicants, and a pilot with a real community fund once it can run outside the sandbox.
Built With
- ag-grid
- ag-grid-enterprise
- ag-studio
- anthropic
- claude
- google-cloud
- google-cloud-build
- google-cloud-firestore
- google-cloud-run
- google-cloud-scheduler
- next.js
- node.js
- paypal
- paypal-javascript-sdk
- paypal-orders-api
- paypal-payouts-api
- paypal-webhooks
- react
- shadcn-ui
- tailwindcss
- typescript
- vercel-ai-sdk
- zod