Chapter 13

E-Commerce Operations Automation

Chapter 13: E-Commerce Operations Automation

E-commerce operations are full of repetitive, rule-based tasks: syncing order statuses, watching inventory levels, processing refunds, responding to negative reviews. These tasks are predictable and time-consuming — perfect targets for n8n automation. This chapter covers four core scenarios and builds two complete projects: a Shopify new-order Feishu notification and a WooCommerce low-stock supplier email.

Order Status Sync: Platform → Internal Systems

n8n offers a dedicated Shopify Trigger node supporting events like orders/create, orders/paid, orders/fulfilled, and orders/cancelled. For WooCommerce, configure Webhooks in WooCommerce → Settings → Advanced → Webhooks to POST to an n8n Webhook node. For platforms without native n8n nodes (e.g. TikTok Shop), use Cron polling via HTTP Request to the platform's Open API, comparing results to find status changes.

Inventory Alerts: Low-Stock Warnings + Purchase Order Generation

Daily workflow: Cron (8 AM) → HTTP Request (fetch all SKU stock levels from ERP/API) → Code node (filter SKUs below safety stock threshold, calculate reorder quantity) → IF (any low-stock items?) → Feishu alert message + Send Email to procurement with CSV attachment + Google Sheets (log alert record).

// Code node: compute reorder list
const SAFETY_DAYS = 14;
return $input.all()
  .filter(i => i.json.stock <= i.json.avg_daily_sales * SAFETY_DAYS)
  .map(i => ({ json: {
    ...i.json,
    reorder_qty: Math.ceil(i.json.avg_daily_sales * 30 - i.json.stock),
    urgency: i.json.stock === 0 ? 'Out of stock' : 'Low stock'
  }}));

Automated Refund Processing

Switch on order amount: small (<$50) → auto-approve via API + buyer SMS; medium ($50–500) → IF on reason (not received vs. other) → auto-approve or reject with template reply; large (>$500) → push to supervisor + Wait node for human decision. Use Switch + IF nodes — no backend code needed.

Review Monitoring: Negative Review Auto-Response

Poll or Webhook for new reviews → IF (rating ≤ 3) → Code node (classify reason: shipping/quality/service) → Switch (route to shipping-lookup, returns flow, or manual ops notification) → Feishu alert to customer service with review content, buyer ID, order number, and suggested reply template.

Compliance note: Automated review replies must comply with platform rules. Never include incentives to modify reviews — this violates most platform policies and can result in store penalties.

Project: Shopify New Order → Feishu → Google Sheets

Shopify Trigger (orders/create) → Code node (format product list, currency, shipping address) → HTTP Request (Feishu green card with order number, amount, customer, country) → Google Sheets Append Row (log order summary) → IF (order > threshold? → extra notification to management).

// Shopify order Feishu card
{
  "msg_type": "interactive",
  "card": {
    "header": {
      "title": { "tag": "plain_text", "content": "New Order Received!" },
      "template": "green"
    },
    "elements": [{
      "tag": "div",
      "fields": [
        { "is_short": true, "text": { "tag": "lark_md",
          "content": "**Order #**\n{{ $json.order_number }}" }},
        { "is_short": true, "text": { "tag": "lark_md",
          "content": "**Amount**\n{{ $json.currency }} {{ $json.total_price }}" }},
        { "is_short": true, "text": { "tag": "lark_md",
          "content": "**Customer**\n{{ $json.customer.first_name }} {{ $json.customer.last_name }}" }},
        { "is_short": true, "text": { "tag": "lark_md",
          "content": "**Ships to**\n{{ $json.shipping_address.country }}" }}
      ]
    }]
  }
}

Project: WooCommerce Low Stock → Email Supplier

Cron (7 AM) → HTTP Request (WooCommerce REST API GET /wc/v3/products with stock_status=instock) → Code node (filter by stock ≤ low_stock_amount, group by supplier) → Loop Over Items → Send Email (HTML table of SKUs needing reorder per supplier) → MySQL (log purchase request for finance/warehouse team).

WooCommerce API auth: Generate Consumer Key + Consumer Secret in WooCommerce → Settings → Advanced → REST API. Use Basic Auth in n8n HTTP Request (Consumer Key as username, Consumer Secret as password).

Rate this chapter
4.7  / 5  (21 ratings)

💬 Comments