Retrieva Labs

Case study Digital health SaaS

AI SponsorA 24/7 AI recovery-support SaaS with WhatsApp voice and ~90% lower token costs.

The backend for a 24/7 AI sponsor for 12-step recovery: Claude chat with prompt caching, Stripe subscriptions and a WhatsApp voice pipeline.

Client
AI Sponsor
Sector
Digital health SaaS
Engagement
Backend build for a subscription SaaS
Our role
Backend architecture and AI engineering
Status
Production backend

Interface recreation · client data anonymized

lower input-token cost
~90%
lower input-token cost
text and voice support
24/7
text and voice support
automated test categories
12
automated test categories

(01) The challenge

What needed solving.

AI Sponsor gives people in 12-step recovery programs a supportive sponsor they can reach at any hour. The product needed a production backend: empathetic, safe AI conversations, subscription billing, and a way to talk through hard moments by voice instead of typing.

The long system prompt that defines the sponsor's personality, safety guardrails and crisis instructions was resent on every turn, so token costs would scale painfully with usage, and every hop of a voice conversation added latency.

(02) The solution

What we built.

We built the Node.js and Express backend around Claude with a cache-friendly prompt structure: stable instructions first, conversation history next and the new message last. Prompt caching cut input-token costs by about 90%, and the cache-hit rate is monitored alongside latency and spend.

Stripe handles subscriptions, trials and webhooks. Through Twilio and the WhatsApp Business API, users send voice notes that are transcribed with Whisper, answered by Claude and returned as synthesized speech. A 12-category automated test suite covers chat logic, sessions, webhooks and security boundaries.

(03) Architecture

How the system fits together.

  1. 01 · Channels

    • Web chat
    • WhatsApp voice notes
  2. 02 · Understand

    • Whisper transcription
    • Session memory
  3. 03 · Reason

    • Claude, cached prompt
    • Safety guardrails
  4. 04 · Respond

    • Text reply
    • Synthesized voice
  5. 05 · Business

    • Stripe subscriptions
    • Webhooks & tests

(04) Engineering decisions

The choices that made it work.

  1. 01

    Caching as architecture

    Prompt structure was designed around caching from the start, not switched on afterwards.

  2. 02

    A full voice round trip

    Voice note in, Whisper transcription, Claude reply, synthesized voice out, all within a conversational latency budget.

  3. 03

    Isolated test categories

    Chat, sessions, webhooks and security are tested separately, so a regression can't hide behind the audio.

(05) Results

What the client got.

  • About 90% reduction in input-token costs through prompt caching
  • Round-the-clock text and WhatsApp voice conversations
  • Stripe subscriptions with trials and webhooks
  • 12-category automated test suite passing across chat, sessions, webhooks and security
Next case study Enterprise IT & cloudConversational AWS Infrastructure Agent

Taking on new projects

Let’sbuild.

Want results like these? Let's talk.

Book a free 30-minute strategy call with our founder. You’ll leave with a clear view of the right architecture, timeline and next step, whether or not we work together.

  • Reply within 24 hours
  • NDA before you share anything confidential
  • You own the code, prompts and documentation
  • Hours overlap with US, UK, EU and Gulf teams
Or get an instant AI plan with the Project Scoper
Book a free strategy call