E-commerce

Autonomous Email Marketing Engine

Email marketing platforms give merchants tools, but someone still has to segment lists, write copy, choose products, set discounts, and decide timing. For a store with 65,000+ customers, doing this well is a full-time job.

Customer Data 65K+ profiles ML Segmentation RFM + Churn AI Decisions Claude Campaign Personalized Email Behavior Opens, Clicks, Buys Continuous learning

The Challenge

I built this to solve my own problem.

Email marketing platforms like Klaviyo and Mailchimp give merchants tools, but they still require significant manual effort. Someone has to define customer segments, write email copy, decide which products to feature, set discount strategies, and optimize send timing. For a store with 65,000+ customers and over 10 years of purchase history, doing this well is a full-time job I didn’t have time for.

I wanted something different: an email system that could make intelligent decisions autonomously, learning from customer behavior and adapting its strategy without constant intervention.

The Approach

I built a full-stack email marketing engine deeply integrated with Shopify. Not a plugin or template, but a custom platform that handles the entire campaign lifecycle from segmentation to send.

ML-Powered Customer Intelligence

The system builds a comprehensive profile of every customer using multiple ML models trained on 10+ years of purchase history:

  • RFM segmentation — Recency, Frequency, and Monetary scoring places each customer into segments like “Champions,” “At Risk,” or “Lost,” using KMeans clustering
  • Churn prediction — a Random Forest model predicts which customers are likely to stop purchasing, allowing preemptive re-engagement
  • Behavioral signals — a Shopify web pixel captures storefront browsing events (product views, collection browsing, cart activity), feeding real-time intent signals into customer profiles

AI Decision Engine

For each potential email send, the system uses Claude with Structured Outputs to make a series of decisions:

  1. Should this customer receive an email? — based on engagement history, recent purchases, and unsubscribe risk
  2. What type of campaign? — re-engagement, upsell, winback, product recommendation, or welcome sequence
  3. What tone and content? — professional, friendly, urgent, or conversational, matched to the customer’s segment
  4. Should a discount be offered, and how much? — with configurable guardrails to prevent over-discounting

If the AI decision fails (network error, model timeout), the system falls back to rule-based defaults rather than skipping the customer entirely.

Journey Engine

Beyond one-off campaigns, the system orchestrates multi-step email sequences:

  • Welcome series — triggered automatically when Shopify creates a new customer
  • Scheduled sequences — recurring campaigns at configurable intervals
  • Per-customer state tracking — knows exactly where each customer is in each journey
  • Reply handling — a SendGrid inbound webhook captures customer replies, matches them to the original campaign, and surfaces them in a Reply Inbox

Compliance Built In

Email compliance isn’t optional. The system implements RFC 8058 one-click unsubscribe headers, maintains a consent ledger with full audit trail, handles GDPR deletion workflows via Shopify webhooks, and enforces CAN-SPAM requirements on every send.

The Results

The platform is in supervised rollout. Campaigns are being generated, segmented, and queued autonomously, while I review output quality before enabling fully automatic sends. The system processes 65,000+ customer profiles, segments them using ML models trained on a decade of purchase data, and generates personalized email content without manual intervention.

The architecture is built as a white-label platform with multi-tenant support, deployed on Railway with the Shopify app embedded directly in the admin sidebar. The intelligence engine (Python/FastAPI) communicates with the Shopify app (Remix) over private networking.

I built this to replace my own manual email marketing workflow, but the platform is designed to work for any Shopify merchant.

Services: AI Agent Development · AI Workflow Automation

Have a similar challenge?

Let's discuss how AI can help your team.

Get in Touch