← All Projects
01 2026 Automation Architect

Shopify — DTC Commerce Automation Suite

Revenue recovery, retention, AI support and payment reconciliation for a Shopify brand selling across the US, Canada and Australia

ShopifyKlaviyoGorgiasn8nStripeOpenAIPostgreSQLShopify Admin API (GraphQL)Slack

Context

The brand was growing across three markets, but the operation hadn't kept up. Shoppers abandoned checkouts with no follow-up beyond a generic email. Customers who loved the product forgot to reorder before running out. The support team spent most of its day answering "where is my order?" by hand. And orders paid through corporate agreements sat as "pending" in Shopify until someone cross-checked the billing system and marked them paid manually — blocking fulfillment and distorting revenue reports.

Solution

The suite is made of four automations that share one principle: each system does what it's best at. Klaviyo owns customer messaging, Shopify owns the order, Gorgias owns the human conversation, and n8n orchestrates everything that crosses those boundaries.

1. Abandoned checkout recovery (Klaviyo). A three-step email and SMS flow triggered by Shopify's Started Checkout event. The first message is a plain reminder with the cart contents; the second adds social proof from product reviews; the third offers a single-use incentive only to first-time buyers and carts above a value threshold — so returning customers are never trained to wait for a coupon. The flow exits the moment an order is placed, and SMS is sent only to subscribers with recorded consent under TCPA, CASL and the Australian Spam Act.

2. Replenishment and repeat purchase (Klaviyo + n8n). Each consumable SKU has a consumption window. n8n calculates when each customer is about to run out — using their own purchase history when available and the SKU default otherwise — and writes that date to their Klaviyo profile. A date-triggered flow reaches the customer a few days before they run out, with a one-click link to a prefilled cart.

3. AI support agent (embedded chat + Gorgias). A chat widget embedded in the storefront, backed by an AI agent with direct, read-only access to Shopify and carrier tracking. It answers order status, shipping times, product and policy questions with live data instead of canned responses. Order details are only revealed after the shopper verifies with order number and email. When a request is ambiguous, involves money, or the customer is frustrated, the agent opens a Gorgias ticket with the full transcript, the order context and a suggested next action — so the human picks up without asking the customer to repeat themselves.

4. Agreement payment reconciliation (Stripe + n8n + Shopify Admin API). Orders placed under corporate agreements are billed through Stripe invoices, outside Shopify. Each invoice carries the Shopify order ID in its metadata. When Stripe fires the invoice.paid event, n8n verifies the webhook signature, locates the matching order, confirms the amount matches and the order is still pending, then marks it as paid through the Admin API, tags it as charged and attaches a note with the Stripe invoice ID and payment date. The workflow is idempotent: Stripe's retried webhooks never create duplicate updates. Any mismatch — wrong amount, missing order, already paid — is never auto-resolved: it goes to Slack for human review.

Key Decisions

  • Klaviyo for messaging, n8n for logic. Klaviyo's flows, deliverability and consent management are hard to beat, so messaging stays there. Custom calculations like per-customer replenishment dates live in n8n and feed Klaviyo through profile properties — the marketing team keeps editing copy and timing without touching code.
  • Incentives are earned, not default. Discounts in the recovery flow are gated by cart value and customer history to protect margin.
  • The agent reads, humans decide. The support agent has read-only access. Anything with financial impact — refunds, cancellations — is escalated with context, never executed autonomously.
  • Strict matching over convenience. Marking an order as paid affects revenue, tax reporting and fulfillment. The reconciliation only acts on exact matches; everything else is flagged.
  • Compliance by market. Consent handling was designed for three different regulatory regimes from day one, not retrofitted.

Results

  • Abandoned checkouts followed up across email and SMS within the first hour, with incentives reserved for first-time buyers on qualifying carts — revenue recovered without eroding margin
  • Replenishment reminders timed to each customer's own buying rhythm instead of a fixed calendar
  • Order status, shipping and product questions answered instantly, 24/7, with live store data
  • Escalated tickets arrive in Gorgias with full transcript and order context — no customer is asked to repeat their issue
  • Agreement orders marked as paid within a minute of Stripe confirming payment, replacing a manual cross-check between two systems
  • Every automated payment update leaves an audit trail with Stripe reference and timestamp

Architecture

Shopify (Store)
  ├─ Started Checkout ──→ Klaviyo: Abandoned Checkout Flow
  │     ├─ Email 1 · 1h  (cart reminder)
  │     ├─ Email/SMS 2 · 24h  (social proof · consent-gated SMS)
  │     ├─ Email 3 · 48h  (conditional split: new customer + cart value → incentive)
  │     └─ Exit on Placed Order
  │
  ├─ Order Fulfilled ──→ n8n: Replenishment Engine
  │     ├─ SKU consumption windows (PostgreSQL)
  │     ├─ Per-customer reorder interval from purchase history
  │     └─ Klaviyo API → profile property: next_reorder_date
  │           └─ Klaviyo: Date-Triggered Replenishment Flow → prefilled cart link
  │
  └─ Storefront Chat Widget ──→ n8n: Support Agent (LLM)
        ├─ verify_customer (order # + email)
        ├─ get_order_status (Shopify Admin API)
        ├─ track_shipment (carrier tracking)
        ├─ search_products / get_policy
        └─ escalate_to_human → Gorgias API (transcript + order context + suggested action)

Stripe (invoice.paid)
  └─ Webhook ──→ n8n: Agreement Reconciliation
        ├─ Verify Stripe signature
        ├─ Idempotency check (event already processed?)
        ├─ Read shopify_order_id from invoice metadata
        ├─ Validate amount + financial status = pending (Shopify GraphQL)
        ├─ ✓ orderMarkAsPaid → tag "charged" → note (Stripe invoice ID + date)
        └─ ✗ mismatch → Slack alert for manual review