Inspiration

Monthly donors keep small nonprofits running: monthly giving was 27% of nonprofits' online revenue in 2025 (M+R Benchmarks 2026). Yet 1 in 10 new monthly donors stop within two months, and some of those losses are not choices at all. A card expires, a balance runs short, PayPal's charge fails, and nobody notices: not the donor, and not the food bank. A small nonprofit has no one watching for it.

What it does

Lifeline watches a food bank's monthly PayPal gifts:

  1. PayPal tells Lifeline the moment a gift fails. The webhook's signature is checked, and a rescue opens by itself.
  2. The agent looks into it. It writes a plan, reads the donor's PayPal subscription and giving history with read-only tools, and explains in one plain sentence why the gift failed. Then it suggests the fixes PayPal can actually carry out, and drafts a kind note.
  3. The fundraising officer approves one fix. Lifeline carries it out on PayPal (retry the charge, pause, lower the gift, forgive the month, cancel, or resume later) or sends the note, then watches until the gift comes back.
  4. Ask Lifeline, any time: a chat on every page that answers from live data, keeps every conversation (New chat and History), reads attachments (a PDF or photo), and remembers what you tell it about a donor. The agent then acts on that, for example offering a lower gift to a donor in hardship.
  5. Reports: an AG Studio dashboard over the same data, where AG Studio's own AI builds a chart from a sentence.

Every judge gets a private practice copy of the food bank, so no one uses up another judge's rescue. In a copy, a fix that would change PayPal does the real PayPal reads, then shows the exact Subscriptions API call it would send, without sending it. Notes really go to the test inbox.

How we built it

  • PayPal (sandbox):
    • Subscriptions v1 through the PayPal TypeScript SDK from APIMatic's PayPal Context Plugin: getSubscription, captureSubscription (outstanding balance), suspendSubscription, activateSubscription, patchSubscription (price and outstanding balance) and cancelSubscription.
    • Webhooks, verified with PayPal's certificate check on the raw bytes: BILLING.SUBSCRIPTION.PAYMENT.FAILED, PAYMENT.SALE.COMPLETED and the subscription status events.
    • The donors are real sandbox subscriptions on a $1 daily test plan that stands in for a monthly gift, so a real failure happens within a day. Notes to donors say "your regular gift".
  • AI: OpenAI gpt-5.4-mini on the Responses API.
    • A forced plan step, read-only tools and a schema-checked diagnosis.
    • Code drops any fix PayPal can't carry out (PayPal can't move a billing date, so Lifeline never offers to).
    • If the model is unavailable, the rescue still opens with standard fixes and says so.
  • Safety in code:
    • Each write to PayPal is claimed in the database before the call, so a double click can't act twice.
    • An answer that's lost is settled by re-reading PayPal, never guessed.
    • Only a person's approval starts a write.
  • AG Studio 3.0 for Reports, with its agents proxied through our server so the model key never reaches the browser, and a custom giving-pulse widget.
  • App: Next.js 16 on Vercel, Neon Postgres, Resend for the donor note.
  • APIMatic: we installed the plugin partway through and followed its workflow: a contract sheet (paypal-plan.md) for every call, and tests that run the real SDK against a fake PayPal in PayPal's wire format.

Challenges we ran into

  • Making a real failure happen. PayPal's sandbox has no switch for "this payment fails". We put a donor on a daily plan and removed her funding, so PayPal's own charge fails and sends the real event.
  • The live recovery taught us three things (3 Nov 2026). We added a card back and approved Retry.
    • PayPal took about two minutes to complete the capture, and the SDK couldn't read its first reply. Lifeline correctly recorded "unknown", not "failed". But the next click checked "is anything owed?" first, and so never confirmed its own charge. Now it re-reads PayPal for its own charge first.
    • One capture of the outstanding balance paid three failed days, but only one rescue closed. Now one completed payment closes every open rescue for that donor.
    • The recovered total counted the same dollars twice. Now each rescue counts its own failed gift.
  • Writes that must never repeat: claim first, send PayPal's request id, and re-read when the answer is lost.
  • Judges sharing one food bank would use up each other's rescues. Hence the practice copies: PayPal ids became unique per workspace, and PayPal's webhooks only ever update the real food bank.

Accomplishments that we're proud of

  • The agent's eval suite: 10 scenarios, each run 3 times against the real model: first misses, repeat failures, hardship Sam told it about, a gift too small to lower, nothing owed, a suspended gift, two prompt injections hidden in a donor's PayPal name, and PayPal not answering. 30/30 runs passed (348/348 checks), the right fix 30/30 times, injections resisted 6/6, about 7 s and half a cent per case. The evals found two real problems, now fixed: the agent ignored a hardship note from Sam, and once returned a blank note.
  • A real rescue, end to end, on the live site and real PayPal sandbox APIs: a signed failure event → a rescue → a diagnosis in 8.7 s → an approved note to the test inbox → Retry → $3.00 captured → PayPal's signed sale event → recovered → Resume → the subscription active again.
  • A second real rescue, filmed for the video (7–8 Nov 2026): Cora's gift failed → the agent suggested a note → Sam changed one word and approved → Cora put her card back → PayPal's own retry the next morning took the gift → Lifeline marked it recovered on PayPal's signed sale event. One approval, no second charge attempt from Lifeline.
  • 31 tests: the PayPal fixes against a fake PayPal, the practice copies, and webhook signatures.

What we learned

Most of the work is in what surrounds the model, not the model itself:

  • tools that can only read;
  • code that filters what the AI suggests;
  • one human approval for every change;
  • treating every lost answer from PayPal as "unknown" until PayPal says otherwise.

What's next for Lifeline

  • Many nonprofits through PayPal's partner onboarding.
  • Card-updater partners, so an expired card fixes itself.

Built With

Share this project:

Updates

Submission history