All Field Notes
E-COMMERCE · 9 MIN READ

The Shopify automation playbook with n8n, Klaviyo, and Slack

TL;DR · THE WORKFLOW

Shopify order → AI segments the customer (VIP · returning · first-time · churn-risk · win-back) → Clearbit enriches the email domain → Klaviyo flow updates with the new tag → if order is above threshold, ping #sales in Slack. Six nodes, 2 seconds end-to-end, A$3,200 to build, +19% LTV in our reference deployment.

This is the workflow NexFlow has shipped sixteen times for direct-to-consumer brands on Shopify. It is not glamorous. The glamour is the result: every order routes to the right Klaviyo flow within two seconds, VIP orders alert the sales team in Slack with context, and the merchandising team sees customer tags they trust. The brand we built it for first runs 11,000+ orders/week and lifted lifetime value 19% in the first quarter.

The six nodes — annotated

Node 1 · Shopify webhook trigger

Subscribe to orders/create in Shopify Admin (Settings → Notifications → Webhooks). JSON format, latest API version. The webhook URL is generated by the n8n Webhook node — keep it behind HTTPS only, never log the URL anywhere public.

Edge case here: Shopify retries failed deliveries with exponential backoff up to 19 times over 48 hours. If your n8n is down for an hour, you'll get a thundering herd when it comes back. Mitigation: idempotency, covered below.

Node 2 · OpenAI segmentation

Pass the order JSON (plus the customer's prior-order count from Shopify if available) to an OpenAI node. We use gpt-4o-mini for this — fast, cheap (under US$0.001/order at typical volume), and reliably structured when you constrain the output.

The system prompt is short:

You receive a Shopify order JSON. Return exactly one
of these five segment values, no prose:

  VIP                  – order ≥ $200 OR 4+ prior orders
  returning-high-LTV   – 2-3 prior orders, current ≥ $80
  first-time           – first order
  churn-risk           – prior orders, none in 120+ days
  win-back             – any tagged "win-back" upstream

Output JSON: { "segment": "..." }
No explanation. No additional fields.

Temperature 0. Validate the response against an enum schema; if it fails validation, retry once, then fall back to returning-high-LTV as a safe default. Never let an unrecognised string flow downstream — it will silently miss your Klaviyo flow.

Node 3 · Clearbit enrichment (conditional)

Only fire this for orders above a threshold (US$100 is our default). Clearbit Reveal costs ~US$0.10/lookup; you do not want it on every $9 order. Cache results for 24 hours in n8n's static data store, keyed by email domain — repeat customers don't re-trigger.

Node 4 · Klaviyo profile update

POST to Klaviyo's /api/profile-import/ endpoint with the customer's email, the segment tag (as a Klaviyo custom property), the enriched company name and industry if Clearbit returned them, and a last_order_segmented_at timestamp.

Klaviyo flows you set up in their UI pick up these tags and route accordingly: VIP cross-sell, first-time onboarding, churn-risk win-back. The n8n workflow doesn't dictate the email content — that stays in Klaviyo where the marketing team lives.

Node 5 · IF branch · VIP or high-value

Standard n8n IF node. Condition: segment === 'VIP' OR order.total_price > 200. True branch fires Node 6; false branch ends the workflow.

Node 6 · Slack alert to #sales

Post a Block Kit message to a dedicated channel with: customer name, email, order total, AI segment, enriched company (if any), and a deep-link to the order in Shopify admin. The deep-link is critical — sales teams will click it within 30 seconds for a real VIP, and the time saved compounds over the year.

The four edge cases we always hit

1 · Webhook duplicates

Shopify retries on any non-2xx response. If your downstream call to Klaviyo is slow and Shopify times out, you get the same order twice. Mitigation: at the top of the workflow, dedupe on order.id using an n8n static-data check; skip if seen in the last hour. Five-line fix, prevents the most common production bug.

2 · OpenAI returns invalid JSON

Even at temperature 0, gpt-4o-mini occasionally adds a sentence before the JSON. Use response_format: { "type": "json_object" } on the OpenAI call to force JSON-mode output; combine with a Zod-style schema validation in the next node. Reject and retry once on validation failure; fall back to returning-high-LTV after the retry fails. We see this fire approximately 1 in 4,000 calls — rare, but bad when it happens.

3 · Klaviyo rate limits

Klaviyo's per-account rate limit is 150 requests/second on the profile-import endpoint as of 2026, but the burst limit is 75. A Black Friday spike will exceed this. Mitigation: queue the Klaviyo step through an n8n Wait node with a small jitter (0-300ms) on bursts above 50 orders/minute. Cheaper than upgrading your Klaviyo tier.

4 · Refunds and order edits

A customer cancels their VIP order an hour later. Your Slack ping is now misleading and your Klaviyo segmentation is wrong. Mitigation: subscribe to orders/cancelled and orders/updated webhooks separately and run a compensating workflow that posts a follow-up to Slack and re-runs segmentation. Don't try to be cute about it — a second clear message is better than a silent correction.

KEY TAKEAWAYS
  • Six nodes, two seconds end-to-end, ~US$0.001 per order in OpenAI cost.
  • Idempotency, JSON-mode, rate-limit queueing, and refund handling are the four production must-haves.
  • Keep email content in Klaviyo; the n8n flow only sets the segment tag and lets Klaviyo do the rest.
  • Slack alert pays for itself the first time a sales rep responds to a VIP within 60 seconds.
  • NexFlow ships this build at A$3,200 one-off. Typical payback: 5-8 weeks via LTV lift.

Frequently asked questions

Can I do this with Zapier instead?

You can — the Shopify, OpenAI, Clearbit, Klaviyo, and Slack apps are all on Zapier. The cost will be 5-10× higher because each step consumes a task and you'll burn 4-6 tasks per order. At 11,000 orders/week, that's ~250,000 tasks/month, which puts you on Zapier's US$799+ Company plan. The same workflow on self-hosted n8n is ~US$20/month in compute. Not contest-able above ~5k orders/month.

What about using Shopify Flow (the built-in tool)?

Shopify Flow is free and excellent for tag-and-fire workflows that stay inside Shopify and a small set of approved apps. The moment you need a custom AI segmentation step, a custom Clearbit call with caching, or anything outside Shopify's app ecosystem, you outgrow Flow. Most clients we work with use both: Shopify Flow for the things it does well, n8n for the rest.

How long does this take to ship?

Two weeks on NexFlow's Spark plan: three days design and sandbox build, one week shadow run beside the brand's existing process, two days for the Klaviyo flow templates if you don't already have them. The clock starts the day after the paid 60-minute deep map.

Run a Shopify store?

We ship this workflow as the baseline and tune it to your tagging conventions, your Klaviyo flows, and your sales-team rhythm. 15-minute map call to see if you're ready: US$50, credited.

Sources

  1. Pricing and rate-limit figures from Klaviyo Developer Docs, Shopify Admin API Docs, and OpenAI API Docs, as of May 2026.
  2. NexFlow internal: this workflow shipped 16 times between June 2024 and April 2026. Median order volume at deployment: 4,200/week. Aggregate orders processed: 1.34M.