Inspiration

When subscription customers start cancelling, the usual fix is a discount for everyone. It feels safe, but most of that money goes to people who were never going to leave, while the people leaving over price are only a small share. You also can't easily test a pricing change without risking real revenue, so most merchants guess.

I wanted a tool where an AI agent does the analysis and you test a decision on a model of your own customers before anything changes. When you approve one, it's carried out in PayPal, and what customers actually do updates the model.

What it does

Aurrery is a decision workspace for subscription merchants.

  1. You state a goal, for example "reduce churn without giving away margin".
  2. An AI agent investigates. Gemini reads customer cancellation feedback and sorts each message into "leaving over price" or "leaving for another reason". It then sets rules, compares candidate strategies on a digital twin of the subscriber base, and stress-tests the best ones.
  3. The twin simulates 400 possible futures for each strategy, so you see a range of outcomes, not a single guess. In the demo, a broad 20% discount gives away about $4,000 and still loses over $1,000 in value, and it does worse than doing nothing in about three of four futures. The agent instead proposes a 25% save offer only to customers cancelling over price.
  4. Every number is labelled as observed, estimated from history, or assumed. The stress test pushes only the assumed numbers to a pessimistic level, so you can see whether the decision still holds if the guesses are wrong.
  5. You approve one exact action. It names the price, the customers it applies to and its duration, and is locked by a hash. Aurrery then carries it out through the PayPal Subscriptions API: it changes the price ($24 → $18), reads the subscription back and records what PayPal actually reports, not what was requested.
  6. It learns from the outcome. Annual-plan offers go out as PayPal plan-change approvals. When a customer accepts or declines, the twin updates; after one acceptance, the core segment's annual uptake moved from 12% to about 15%.
  7. It works for other merchants. Import a subscription history CSV, and optionally a feedback CSV, and Aurrery builds a twin of that business. The same 20% offer that loses money for the coffee merchant makes over $2,000 in simulation for a dog-treat box. Imported merchants are simulate-only.

The agent has no tool that can execute anything. It can only propose, and a merchant must confirm and approve before PayPal is touched.

How I built it

  • App: Next.js 16, React 19 and TypeScript, styled with Tailwind v4. The comparison grid uses AG Grid, and the fan charts and range bars are custom SVG.
  • Digital twin: a pure TypeScript Monte Carlo model.
    • Customers are grouped by segment, cancellation reason, plan and discount state.
    • Each month models signups, cancellations scaled by price sensitivity, payment failures, offer expiry and customers moving between segments.
    • Cancel rates are estimated from history with Bayesian updating. Price sensitivity and discount effects start as labelled assumptions with wide uncertainty.
    • Strategies share the same random draws for customers they don't touch, so differences come from the decision rather than noise.
    • Simulations run in a separate worker process.
  • AI: Gemini 3.5 Flash-Lite.
    • Feedback classification: I evaluated it against a hand-labelled set of 200 messages. It agreed on 96% and classified every pilot customer correctly.
    • Agent: it runs in a bounded loop with seven strict tools, capped at 10 tool calls, 11 turns and 48,000 tokens.
    • Displayed numbers: these come from typed simulation results, never from the model's prose.
  • PayPal: Sandbox Subscriptions API and webhooks.
    • Price changes are sent as a patch, followed by a read-back.
    • Annual offers are created as a yearly plan plus a plan-change approval link for the customer.
    • Webhooks are only trusted after PayPal's verification call confirms them.
    • Every execution claims its target customers in one database step, so the same action can't run twice.
    • If PayPal's response is unclear, Aurrery stops for a manual check instead of retrying.
  • Data and hosting:
    • A Turso (libSQL) ledger holds proposals, executions, observations and audit records.
    • It's hosted on Render.
    • Admin sign-in is required for any action that changes PayPal.
  • Testing:
    • The test suite uses Vitest.
    • Recorded agent runs replay offline through the real tools and simulator.
    • Input validation uses Zod.

Challenges I ran into

  • There was no price-change history to learn from. The twin can't measure price sensitivity from data that doesn't exist. Instead of hiding that, I labelled those numbers as assumptions and built the stress test around them.
  • Keeping the AI honest. Early runs described assumptions as observed facts and confused the median with the mean. I moved every displayed number and label onto typed simulation results, so the model's text explains the numbers but never supplies them.
  • Safe execution against a real API. PayPal has no conditional price update, and a network timeout can leave it unclear whether a change happened. I built a claim-then-execute flow that refuses to retry automatically and leaves an uncertain action for the merchant to check.
  • Agent budgets. Free-tier limits and token caps meant the agent sometimes ran out mid-investigation. I tuned the limits, pacing and tool design until full runs completed reliably on free hosting.

Accomplishments that I'm proud of

  • A real closed loop: the AI proposes, the merchant approves, PayPal executes, Aurrery verifies the result, and the model learns from it.
  • The demo shows the AI-assisted answer beating the obvious one. The broad discount most merchants would reach for loses money, and the twin shows why.
  • The app is open about uncertainty: every number says where it came from, and the stress test shows when a "win" could disappear.
  • The AI never gets the power to move money. It can only propose.

What I learned

  • A forecast is only useful if it's clear which parts are measured and which are guessed.
  • Let the AI decide what to investigate, but let typed code produce the numbers people act on.
  • With payment APIs, the hard part isn't the call that changes the price. It's knowing for certain what happened afterwards.

What's next for Aurrery

  • Connect real merchant data directly from PayPal subscription history instead of CSV uploads.
  • Learn price sensitivity from experiments. Run small, approved price tests on a few customers and feed the results back, so assumptions become estimates.
  • Add more actions: pauses, plan downgrades and win-back offers, each under the same simulate-then-approve flow.
  • Scheduled monitoring: the agent notices rising cancellations and proposes a response for the merchant to review.

Built With

Share this project:

Updates

Submission history