Skip to content
All projects

AI Automation · E-commerce Retention

Shopify–Klaviyo AI Retention Agent

Portfolio Demonstration

A human-in-the-loop retention planning dashboard that analyzes mock Shopify customer and order behavior, applies deterministic segmentation and safety rules, prepares guarded AI-assisted Klaviyo campaign drafts, and records internal review decisions without sending messages or modifying live provider data.

Shopify–Klaviyo AI Retention Agent dashboard showing customer segments, risk levels, consent, and internal campaign metrics

Problem

E-commerce teams need a practical way to identify retention opportunities and prepare personalized campaign ideas, but fully automated messaging creates risks involving customer consent, refunds, incorrect segmentation, invented offers, and unreviewed AI-generated copy.

System Design

I built a mock-first retention planning application where deterministic business rules remain in control. Commerce metrics, customer segmentation, risk level, consent eligibility, refund safeguards, campaign type, and channel eligibility are calculated by the rule engine. AI is limited to drafting internal campaign wording after those decisions are made. Every campaign draft must be approved, edited and approved, or rejected by a human reviewer.

Workflow Stages

  1. 01Retrieve normalized mock Shopify and Klaviyo customer context
  2. 02Calculate commerce metrics deterministically
  3. 03Assign a primary customer segment using documented precedence
  4. 04Evaluate risk, consent, refunds, and retention eligibility
  5. 05Produce a safe deterministic campaign recommendation
  6. 06Generate an internal AI-assisted campaign draft when eligible
  7. 07Require a human reviewer to approve, edit and approve, or reject the draft
  8. 08Record plan generation and review decisions in the audit log
  9. 09Keep every approved plan internal — nothing is sent, scheduled, activated, or synchronized

Tools Used

  • Next.js
  • React
  • TypeScript
  • Tailwind CSS v4
  • Zod
  • Anthropic SDK
  • Node.js
  • Local JSON and JSONL demo persistence
  • Shopify Admin GraphQL read-only adapter architecture
  • Klaviyo read-only adapter architecture

Safety & Human Review

  • Deterministic rule engine controls segmentation, risk, consent, and channel eligibility — AI cannot override these decisions
  • AI is limited to drafting internal campaign wording only, after all deterministic decisions are made
  • Every campaign draft requires human approval, edit-and-approve, or rejection before becoming an internal plan
  • Approval never sends, schedules, activates, or creates a live Klaviyo campaign
  • Consent-aware email/SMS suppression and refund-sensitive recommendation safeguards
  • Mock-first Shopify and Klaviyo read-only adapters — no live provider mutation
  • Original AI-generated drafts preserved separately from human-edited versions
  • Append-only audit history of plan generation and review decisions

Implementation Evidence

Real screenshots of the working system — collapsed by default so this page stays readable.

What's Working

168 of 168 automated verification checks passed across Stages 2–6, along with a clean TypeScript type-check, zero ESLint errors or warnings, and a successful production build. The dashboard, customer directory, campaign review, and audit pages are functional in mock mode. No live Shopify, Klaviyo, or Anthropic request occurred during verification, and no customer message, campaign, discount, consent update, profile update, or provider mutation occurred.

Limitations & Confidentiality

This is a functional portfolio demonstration using fictional customers and mock provider modes. Live Shopify, Klaviyo, Anthropic, Supabase, authentication, and production deployment integrations are not presented as completed.

What I'd Improve Next

Possible next improvements (not yet built or verified): Supabase persistence, staff authentication and role-based access, live Shopify installation and credential configuration, a live Klaviyo read-only connection, optional live Anthropic drafting, production deployment and monitoring, and expanded campaign-performance reporting. These are future possibilities, not completed features.

Have a similar workflow to automate?

I'll tell you honestly whether automation is the right fix.