n8n Automation

n8n E-commerce Automation: Shopify Order Workflows

Petru Constantin
••15 min read
#n8n#Shopify#e-commerce#order automation#workflow automation

This guide builds Shopify automations in n8n for order handling, inventory alerts, customer emails and fulfillment, using Code nodes and the Shopify Admin API. Shopify can deliver the same webhook more than once and its REST Admin API is now legacy, so the examples verify signatures on the raw body, keep the webhook ID for deduplication and create fulfillments through the GraphQL Admin API.

Petru Constantin is the founder of DeviDevs and designed the multi-agent platform the company runs on, with guardrails enforced in code. Code examples are written against the n8n 2.47.7 (stable) and Shopify Admin API 2026-10 documentation.

Shopify Integration Setup

API Configuration

In n8n, create a Shopify credential with the Access token method, which the n8n docs recommend for a single store: enter the shop subdomain, the Admin API access token and the app secret key of the custom app you create in Shopify. The older API key method is deprecated, because Shopify no longer generates API keys with passwords. For the Shopify node, n8n lists the read_orders, write_orders, read_products and write_products Admin API scopes; add the inventory, customer and fulfillment scopes that the Shopify endpoints you call require. The examples below use Admin API version 2026-10.

Webhook Configuration

// Code node (Run Once for All Items) after a Webhook node with "Raw Body" enabled.
// Self-hosted: allow crypto with NODE_FUNCTION_ALLOW_BUILTIN=crypto.
// $env is blocked in the Code node by default on n8n 2.x (N8N_BLOCK_ENV_ACCESS_IN_NODE).
const crypto = require('crypto');
 
const item = $input.first();
const headers = item.json.headers;
const hmacHeader = headers['x-shopify-hmac-sha256'];
const topic = headers['x-shopify-topic'];
const webhookId = headers['x-shopify-webhook-id'];
const secret = $env.SHOPIFY_WEBHOOK_SECRET; // the app's client secret
 
const binaryKey = Object.keys(item.binary ?? {})[0];
if (!binaryKey || !hmacHeader || !secret) {
  throw new Error('Missing raw body, HMAC header or secret');
}
const rawBody = await this.helpers.getBinaryDataBuffer(0, binaryKey);
 
// Shopify sends a base64-encoded HMAC-SHA256 of the raw body
const computed = crypto.createHmac('sha256', secret).update(rawBody).digest();
const received = Buffer.from(String(hmacHeader), 'base64');
 
if (received.length !== computed.length || !crypto.timingSafeEqual(received, computed)) {
  throw new Error('Invalid webhook signature');
}
 
const [resource, action] = String(topic ?? '').split('/');
 
return [{
  json: {
    resource,
    action,
    webhookId, // store it and skip IDs you have already processed
    data: JSON.parse(rawBody.toString('utf8')),
    receivedAt: new Date().toISOString(),
    verified: true
  }
}];

Order Processing Workflows

New Order Handler

// Code node (Run Once for All Items): normalise an orders/create payload
const order = $input.first().json.data;
 
const orderData = {
  orderId: order.id,
  orderNumber: order.order_number,
  orderName: order.name,
  createdAt: order.created_at,
 
  // Customer info
  customer: {
    id: order.customer?.id,
    email: order.customer?.email || order.email,
    firstName: order.customer?.first_name,
    lastName: order.customer?.last_name,
    phone: order.customer?.phone || order.phone,
    totalOrders: order.customer?.orders_count || 1,
    totalSpent: order.customer?.total_spent || order.total_price
  },
 
  // Order totals
  financials: {
    subtotal: parseFloat(order.subtotal_price),
    totalTax: parseFloat(order.total_tax),
    totalShipping: parseFloat(order.total_shipping_price_set?.shop_money?.amount || 0),
    totalDiscount: parseFloat(order.total_discounts),
    totalPrice: parseFloat(order.total_price),
    currency: order.currency
  },
 
  // Line items
  items: (order.line_items || []).map(item => ({
    id: item.id,
    productId: item.product_id,
    variantId: item.variant_id,
    title: item.title,
    variantTitle: item.variant_title,
    sku: item.sku,
    quantity: item.quantity,
    price: parseFloat(item.price),
    grams: item.grams || 0,
    totalDiscount: parseFloat(item.total_discount),
    requiresShipping: item.requires_shipping,
    fulfillmentStatus: item.fulfillment_status
  })),
 
  // Shipping info
  shipping: {
    method: order.shipping_lines?.[0]?.title,
    address: order.shipping_address ? {
      name: `${order.shipping_address.first_name} ${order.shipping_address.last_name}`,
      company: order.shipping_address.company,
      address1: order.shipping_address.address1,
      address2: order.shipping_address.address2,
      city: order.shipping_address.city,
      province: order.shipping_address.province,
      country: order.shipping_address.country,
      countryCode: order.shipping_address.country_code,
      zip: order.shipping_address.zip,
      phone: order.shipping_address.phone
    } : null
  },
 
  // Flags
  flags: {
    isFirstOrder: (order.customer?.orders_count || 1) === 1,
    hasDiscount: parseFloat(order.total_discounts) > 0,
    isPaid: order.financial_status === 'paid',
    requiresShipping: (order.line_items || []).some(item => item.requires_shipping)
  },
 
  // Discount codes
  discountCodes: order.discount_codes || [],
 
  // Tags and notes (order-level tags; line items have no tags)
  tags: order.tags ? order.tags.split(',').map(t => t.trim()) : [],
  note: order.note,
  noteAttributes: order.note_attributes
};
 
return [{ json: orderData }];

Order Routing Logic

// Code node (Run Once for All Items): route an order by simple criteria
const order = $input.first().json;
const HOME_COUNTRY = 'US'; // ISO 3166-1 alpha-2 code of your shipping origin
 
let route = 'standard';
let priority = 'normal';
let warehouse = 'main';
 
// High value orders
if (order.financials.totalPrice > 500) {
  priority = 'high';
}
 
// First-time customer
if (order.flags.isFirstOrder) {
  order.flags.requiresWelcomeEmail = true;
}
 
// Manual review: the order webhook carries no fraud analysis,
// so this example uses an order tag set by your own review rule
if (order.tags.includes('manual-review')) {
  route = 'manual_review';
  priority = 'hold';
}
 
// Express shipping
const shippingMethod = order.shipping.method?.toLowerCase() || '';
if (route !== 'manual_review' &&
    (shippingMethod.includes('express') || shippingMethod.includes('overnight'))) {
  priority = 'urgent';
}
 
// International orders (orders without a shipping address stay on the default route)
const countryCode = order.shipping.address?.countryCode;
if (countryCode && countryCode !== HOME_COUNTRY && route !== 'manual_review') {
  route = 'international';
  warehouse = 'international';
}
 
// SKU-based special handling
const requiresSpecialHandling = order.items.some(item => item.sku?.startsWith('SPECIAL-'));
if (requiresSpecialHandling && route !== 'manual_review') {
  route = 'special_handling';
}
 
return [{
  json: {
    ...order,
    routing: {
      route,
      priority,
      warehouse,
      assignedAt: new Date().toISOString()
    }
  }
}];

Inventory Management

Real-Time Inventory Sync

// Code node (Run Once for All Items): inventory_levels/update handler
const inventoryUpdate = $input.first().json.data;
 
// Process inventory level change
const inventoryData = {
  inventoryItemId: inventoryUpdate.inventory_item_id,
  locationId: inventoryUpdate.location_id,
  available: inventoryUpdate.available,
  updatedAt: inventoryUpdate.updated_at
};
 
// Check for low stock threshold
const lowStockThreshold = 10;
const criticalStockThreshold = 3;
 
let stockStatus = 'normal';
let alertRequired = false;
 
if (inventoryData.available <= 0) {
  stockStatus = 'out_of_stock';
  alertRequired = true;
} else if (inventoryData.available <= criticalStockThreshold) {
  stockStatus = 'critical';
  alertRequired = true;
} else if (inventoryData.available <= lowStockThreshold) {
  stockStatus = 'low';
  alertRequired = true;
}
 
return [{
  json: {
    ...inventoryData,
    stockStatus,
    alertRequired,
    thresholds: {
      low: lowStockThreshold,
      critical: criticalStockThreshold
    }
  }
}];

Multi-Location Inventory Aggregation

// Code node (Run Once for All Items): aggregate inventory levels across locations.
// Input: one item per inventory level with inventory_item_id, location_id,
// available and updated_at (the fields of the inventory level webhook).
const inventoryLevels = $input.all().map(item => item.json);
 
const aggregated = {};
 
for (const level of inventoryLevels) {
  const itemId = level.inventory_item_id;
 
  if (!aggregated[itemId]) {
    aggregated[itemId] = {
      inventoryItemId: itemId,
      totalAvailable: 0,
      locations: [],
      lastUpdated: level.updated_at
    };
  }
 
  aggregated[itemId].totalAvailable += level.available || 0;
  aggregated[itemId].locations.push({
    locationId: level.location_id,
    available: level.available
  });
 
  // Track most recent update
  if (new Date(level.updated_at) > new Date(aggregated[itemId].lastUpdated)) {
    aggregated[itemId].lastUpdated = level.updated_at;
  }
}
 
const results = Object.values(aggregated).map(item => ({
  ...item,
  status: item.totalAvailable <= 0 ? 'out_of_stock' :
          item.totalAvailable <= 10 ? 'low_stock' : 'in_stock',
  needsReorder: item.totalAvailable <= 20
}));
 
return results.map(item => ({ json: item }));

Automated Reorder Workflow

// Code node (Run Once for All Items): draft purchase orders.
// Input: items that need reordering, merged beforehand with your own catalog data
// (supplier, sku, productTitle, unitCost, reorderPoint, reorderQuantity).
// Shopify inventory data alone doesn't contain these fields.
const lowStockItems = $input.all().map(item => item.json);
 
const bySupplier = {};
 
for (const item of lowStockItems) {
  const supplier = item.supplier || 'default';
 
  if (!bySupplier[supplier]) {
    bySupplier[supplier] = {
      supplier,
      items: [],
      totalItems: 0,
      estimatedCost: 0
    };
  }
 
  // Order up to reorderPoint + reorderQuantity
  const reorderPoint = item.reorderPoint ?? 20;
  const reorderQuantity = item.reorderQuantity ?? 50;
  const currentStock = item.totalAvailable;
  const quantityToOrder = Math.max(0, reorderPoint + reorderQuantity - currentStock);
  const unitCost = item.unitCost || 0;
 
  if (quantityToOrder > 0) {
    bySupplier[supplier].items.push({
      sku: item.sku,
      productTitle: item.productTitle,
      currentStock,
      reorderQuantity: quantityToOrder,
      unitCost,
      totalCost: quantityToOrder * unitCost
    });
 
    bySupplier[supplier].totalItems += quantityToOrder;
    bySupplier[supplier].estimatedCost += quantityToOrder * unitCost;
  }
}
 
const purchaseOrders = Object.values(bySupplier)
  .filter(po => po.items.length > 0)
  .map((po, index) => ({
    ...po,
    poNumber: `PO-${Date.now()}-${index + 1}`,
    createdAt: new Date().toISOString(),
    status: 'draft',
    expectedDelivery: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString()
  }));
 
return purchaseOrders.map(po => ({ json: po }));

Customer Communication Automation

Order Confirmation Email

// Code node (Run Once for All Items): order confirmation email.
// Every value from the order is escaped: names, addresses and titles come from customers.
const order = $input.first().json;
 
const escapeHtml = (value) => String(value ?? '')
  .replace(/&/g, '&amp;')
  .replace(/</g, '&lt;')
  .replace(/>/g, '&gt;')
  .replace(/"/g, '&quot;')
  .replace(/'/g, '&#39;');
 
const money = (amount) => new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: order.financials.currency
}).format(amount);
 
const itemsHtml = order.items.map(item => `
  <tr>
    <td style="padding: 10px; border-bottom: 1px solid #eee;">
      ${escapeHtml(item.title)}${item.variantTitle ? ` - ${escapeHtml(item.variantTitle)}` : ''}
    </td>
    <td style="padding: 10px; border-bottom: 1px solid #eee; text-align: center;">
      ${Number(item.quantity)}
    </td>
    <td style="padding: 10px; border-bottom: 1px solid #eee; text-align: right;">
      ${money(item.price * item.quantity)}
    </td>
  </tr>
`).join('');
 
const address = order.shipping.address;
const addressHtml = address ? `
  <p>
    ${escapeHtml(address.name)}<br>
    ${address.company ? escapeHtml(address.company) + '<br>' : ''}
    ${escapeHtml(address.address1)}<br>
    ${address.address2 ? escapeHtml(address.address2) + '<br>' : ''}
    ${escapeHtml(address.city)}, ${escapeHtml(address.province)} ${escapeHtml(address.zip)}<br>
    ${escapeHtml(address.country)}
  </p>
` : '<p>Digital delivery - no shipping required</p>';
 
const emailHtml = `
<!DOCTYPE html>
<html>
<head>
  <style>
    body { font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; }
    .header { background: #2563eb; color: white; padding: 20px; text-align: center; }
    .content { padding: 20px; }
    table { width: 100%; border-collapse: collapse; }
    th { background: #f3f4f6; padding: 10px; text-align: left; }
    .totals { margin-top: 20px; text-align: right; }
    .footer { background: #f9fafb; padding: 20px; text-align: center; font-size: 12px; }
  </style>
</head>
<body>
  <div class="header">
    <h1>Order Confirmed!</h1>
    <p>Order ${escapeHtml(order.orderName)}</p>
  </div>
 
  <div class="content">
    <p>Hi ${escapeHtml(order.customer.firstName || 'there')},</p>
    <p>Thank you for your order! We've received it and are getting it ready.</p>
 
    <h3>Order Details</h3>
    <table>
      <thead>
        <tr>
          <th>Item</th>
          <th style="text-align: center;">Qty</th>
          <th style="text-align: right;">Price</th>
        </tr>
      </thead>
      <tbody>
        ${itemsHtml}
      </tbody>
    </table>
 
    <div class="totals">
      <p>Subtotal: ${money(order.financials.subtotal)}</p>
      ${order.financials.totalDiscount > 0 ? `<p>Discount: -${money(order.financials.totalDiscount)}</p>` : ''}
      <p>Shipping: ${money(order.financials.totalShipping)}</p>
      <p>Tax: ${money(order.financials.totalTax)}</p>
      <p><strong>Total: ${money(order.financials.totalPrice)}</strong></p>
    </div>
 
    <h3>Shipping Address</h3>
    ${addressHtml}
 
    <p>You'll receive another email when your order ships with tracking information.</p>
  </div>
 
  <div class="footer">
    <p>Questions? Reply to this email or contact us at support@example.com</p>
  </div>
</body>
</html>
`;
 
return [{
  json: {
    to: order.customer.email,
    subject: `Order Confirmed - ${order.orderName}`,
    html: emailHtml,
    tags: ['order-confirmation', `order-${order.orderId}`]
  }
}];

Shipping Notification

// Code node (Run Once for All Items): shipping notification for a fulfillments/create payload.
// Shopify notifies the customer itself when the fulfillment is created with notifyCustomer: true;
// send this email only if you turn that off.
// customerEmail isn't part of the fulfillment payload: look the order up by order_id first
// and add its email to the item.
const input = $input.first().json;
const fulfillment = input.data;
const customerEmail = input.customerEmail;
 
const escapeHtml = (value) => String(value ?? '')
  .replace(/&/g, '&amp;')
  .replace(/</g, '&lt;')
  .replace(/>/g, '&gt;')
  .replace(/"/g, '&quot;')
  .replace(/'/g, '&#39;');
 
// Use the tracking URL Shopify stores on the fulfillment instead of guessing carrier URLs
const trackingUrl = fulfillment.tracking_url || null;
 
const emailHtml = `
<!DOCTYPE html>
<html>
<head>
  <style>
    body { font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; }
    .header { background: #059669; color: white; padding: 20px; text-align: center; }
    .content { padding: 20px; }
    .tracking-box { background: #f3f4f6; padding: 20px; border-radius: 8px; margin: 20px 0; text-align: center; }
    .track-button { display: inline-block; background: #2563eb; color: white; padding: 12px 24px; text-decoration: none; border-radius: 6px; margin-top: 10px; }
    .footer { background: #f9fafb; padding: 20px; text-align: center; font-size: 12px; }
  </style>
</head>
<body>
  <div class="header">
    <h1>📦 Your Order Has Shipped!</h1>
  </div>
 
  <div class="content">
    <p>Great news! Your order is on its way.</p>
 
    <div class="tracking-box">
      <p><strong>Carrier:</strong> ${escapeHtml(fulfillment.tracking_company || 'Standard Shipping')}</p>
      ${fulfillment.tracking_number ? `<p><strong>Tracking Number:</strong> ${escapeHtml(fulfillment.tracking_number)}</p>` : ''}
      ${trackingUrl ? `<a href="${escapeHtml(trackingUrl)}" class="track-button">Track Your Package</a>` : ''}
    </div>
 
    <h3>Items Shipped</h3>
    <ul>
      ${(fulfillment.line_items || []).map(item =>
        `<li>${escapeHtml(item.title)}${item.variant_title ? ` - ${escapeHtml(item.variant_title)}` : ''} (x${Number(item.quantity)})</li>`
      ).join('')}
    </ul>
  </div>
 
  <div class="footer">
    <p>Questions about your shipment? Contact us at support@example.com</p>
  </div>
</body>
</html>
`;
 
return [{
  json: {
    to: customerEmail,
    subject: 'Your Order Has Shipped! 📦',
    html: emailHtml,
    tags: ['shipping-notification', `order-${fulfillment.order_id}`]
  }
}];

Fulfillment Automation

Fulfillment Service Integration

// Code node (Run Once for All Items): build a carrier shipment request from the order.
// The field names on the right-hand side follow your carrier's API, not Shopify's.
const order = $input.first().json;
const address = order.shipping.address;
 
if (!address) {
  throw new Error(`Order ${order.orderName} has no shipping address`);
}
 
const GRAMS_PER_LB = 453.592;
 
function mapShippingService(shopifyMethod) {
  const mappings = {
    'Standard Shipping': 'ground',
    'Express Shipping': 'express',
    'Overnight': 'overnight',
    'Free Shipping': 'ground'
  };
  return mappings[shopifyMethod] || 'ground';
}
 
const fulfillmentRequest = {
  orderId: order.orderId,
  orderNumber: order.orderNumber,
 
  shipTo: {
    name: address.name,
    company: address.company,
    street1: address.address1,
    street2: address.address2,
    city: address.city,
    state: address.province,
    postalCode: address.zip,
    country: address.countryCode,
    phone: address.phone
  },
 
  shipFrom: {
    name: 'Your Store',
    street1: '123 Warehouse St',
    city: 'Commerce City',
    state: 'CA',
    postalCode: '90210',
    country: 'US',
    phone: '555-123-4567'
  },
 
  packages: [{
    // Shopify line items carry their weight in grams
    weight: order.items.reduce((sum, item) => sum + (item.grams / GRAMS_PER_LB) * item.quantity, 0),
    weightUnit: 'lb',
    dimensions: { length: 10, width: 8, height: 4, unit: 'in' }
  }],
 
  items: order.items
    .filter(item => item.requiresShipping)
    .map(item => ({
      sku: item.sku,
      description: item.title,
      quantity: item.quantity,
      value: item.price,
      weight: item.grams / GRAMS_PER_LB
    })),
 
  serviceType: mapShippingService(order.shipping.method),
  shipDate: new Date().toISOString().split('T')[0],
  reference: order.orderNumber,
 
  options: {
    signatureRequired: order.financials.totalPrice > 100,
    insurance: order.financials.totalPrice > 200 ? {
      amount: order.financials.totalPrice,
      currency: order.financials.currency
    } : null
  }
};
 
return [{ json: fulfillmentRequest }];

Update Shopify Fulfillment

// Code node (Run Once for All Items): build a GraphQL fulfillmentCreate request
// for an HTTP Request node (POST, JSON body, Shopify credential).
// The REST Admin API is legacy; fulfillments are created from fulfillment orders.
// Input: the carrier response plus fulfillmentOrderId, read earlier from the
// order's fulfillmentOrders with a GraphQL query.
const input = $input.first().json;
const shop = 'your-store'; // shop subdomain
 
const mutation = `
mutation fulfillmentCreate($fulfillment: FulfillmentInput!) {
  fulfillmentCreate(fulfillment: $fulfillment) {
    fulfillment { id status }
    userErrors { field message }
  }
}`;
 
const variables = {
  fulfillment: {
    // Leaving out fulfillmentOrderLineItems fulfills every line item of the fulfillment order
    lineItemsByFulfillmentOrder: [{ fulfillmentOrderId: input.fulfillmentOrderId }],
    notifyCustomer: true,
    trackingInfo: {
      company: input.carrier,
      number: input.trackingNumber,
      url: input.trackingUrl
    }
  }
};
 
return [{
  json: {
    // Check data.fulfillmentCreate.userErrors in the response: GraphQL errors come back with HTTP 200
    endpoint: `https://${shop}.myshopify.com/admin/api/2026-10/graphql.json`,
    method: 'POST',
    body: { query: mutation, variables }
  }
}];

Analytics and Reporting

Daily Sales Summary

// Code node (Run Once for All Items): daily sales summary.
// getHours() uses the time zone of the n8n instance.
const orders = $input.all().map(item => item.json);
 
const metrics = {
  date: new Date().toISOString().split('T')[0],
  totalOrders: orders.length,
  totalRevenue: 0,
  averageOrderValue: 0,
  totalItems: 0,
  newCustomers: 0,
  returningCustomers: 0,
  topProducts: {},
  revenueByHour: new Array(24).fill(0),
  ordersByCountry: {}
};
 
for (const order of orders) {
  metrics.totalRevenue += order.financials.totalPrice;
  metrics.totalItems += order.items.reduce((sum, item) => sum + item.quantity, 0);
 
  if (order.flags.isFirstOrder) {
    metrics.newCustomers++;
  } else {
    metrics.returningCustomers++;
  }
 
  for (const item of order.items) {
    const key = item.sku || item.title;
    if (!metrics.topProducts[key]) {
      metrics.topProducts[key] = { title: item.title, quantity: 0, revenue: 0 };
    }
    metrics.topProducts[key].quantity += item.quantity;
    metrics.topProducts[key].revenue += item.price * item.quantity;
  }
 
  const hour = new Date(order.createdAt).getHours();
  metrics.revenueByHour[hour] += order.financials.totalPrice;
 
  const country = order.shipping.address?.countryCode || 'Unknown';
  metrics.ordersByCountry[country] = (metrics.ordersByCountry[country] || 0) + 1;
}
 
metrics.averageOrderValue = metrics.totalOrders > 0 ?
  metrics.totalRevenue / metrics.totalOrders : 0;
 
metrics.topProducts = Object.entries(metrics.topProducts)
  .sort((a, b) => b[1].revenue - a[1].revenue)
  .slice(0, 10)
  .map(([sku, data]) => ({ sku, ...data }));
 
return [{ json: metrics }];

Error Handling and Monitoring

Workflow Error Handler

// Code node in an error workflow (the workflow starts with an Error Trigger node).
// The Error Trigger output carries the failed execution and workflow, not a custom context.
const { execution, workflow } = $input.first().json;
 
const message = execution?.error?.message || '';
const errorMessage = message.toLowerCase();
 
let category = 'unknown';
let severity = 'medium';
let action = 'log';
 
if (errorMessage.includes('rate limit') || errorMessage.includes('429')) {
  category = 'rate_limit';
  severity = 'low';
  action = 'retry_with_backoff';
} else if (errorMessage.includes('not found') || errorMessage.includes('404')) {
  category = 'not_found';
  severity = 'medium';
  action = 'skip';
} else if (errorMessage.includes('unauthorized') || errorMessage.includes('401')) {
  category = 'auth';
  severity = 'high';
  action = 'alert';
} else if (errorMessage.includes('inventory') || errorMessage.includes('stock')) {
  category = 'inventory';
  severity = 'high';
  action = 'manual_review';
} else if (errorMessage.includes('payment')) {
  category = 'payment';
  severity = 'critical';
  action = 'alert_urgent';
}
 
const errorReport = {
  timestamp: new Date().toISOString(),
  category,
  severity,
  action,
  error: {
    message,
    stack: execution?.error?.stack?.slice(0, 500)
  },
  context: {
    workflowId: workflow?.id,
    workflowName: workflow?.name,
    executionId: execution?.id,   // set only when the failed execution was saved
    executionUrl: execution?.url,
    failedNode: execution?.lastNodeExecuted
  }
};
 
return [{
  json: {
    ...errorReport,
    shouldRetry: action.includes('retry'),
    shouldAlert: action.includes('alert'),
    alertChannel: severity === 'critical' ? 'pagerduty' : 'slack'
  }
}];

Best Practices Summary

  1. Verify webhooks with HMAC-SHA256 over the raw body, using the app's client secret
  2. Answer quickly - Shopify allows five seconds for the whole request, so respond early and move slow work out of the request path
  3. Deduplicate deliveries on X-Shopify-Webhook-Id, because the same webhook can arrive more than once
  4. Build new calls on the GraphQL Admin API - the REST Admin API is legacy since October 1, 2024
  5. Escape customer data before it goes into HTML emails
  6. Route failures to an error workflow that starts with an Error Trigger
  7. Watch stock per location and alert on thresholds you choose
  8. Test on a development store before going live

E-commerce automation with n8n enables scaling operations while maintaining customer experience quality. Start with core order processing and expand to inventory and marketing automation as you grow.


Official references

Related on this site: AI Automation: Zapier vs Make vs n8n - Which One to Choose?, n8n CRM Automation: HubSpot & Salesforce Patterns, n8n Customer Onboarding: End-to-End Automation. More articles in the n8n Automation category.

Want AI agents and automations your business can actually run on?

We ship production AI in fixed two-week sprints, then secure them. Book a 30-minute call to scope yours.

Book a Call

Before you book, you can see what we build, how a sprint works, how our pricing works, what we have already built, or write to us directly.

Weekly AI Agents, Automation & Security Digest

How we build AI agents and automations with Claude Code, plus practical AI security, integrations, and platform notes, delivered weekly.

No spam. Unsubscribe anytime.