{
  "name": "Nodbot - WooCommerce orders to CRM with dedupe",
  "nodes": [
    {
      "parameters": {
        "path": "integration-woocommerce-n8n-order-sync",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "id": "7354fec4-35bc-427c-9936-88bfaf7afe76",
      "name": "WooCommerce Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst headers = $json.headers ?? {};\nconst topic = String(headers['x-wc-webhook-topic'] ?? src.topic ?? 'order.updated').trim();\nconst shop = String(src.shop_domain ?? headers.host ?? 'woocommerce').trim().toLowerCase();\nconst orderId = String(src.id ?? '').trim();\nif (!orderId) throw new Error('No WooCommerce order id');\nconst email = String(src.billing?.email ?? '').trim().toLowerCase();\nconst phone = String(src.billing?.phone ?? '').trim();\nconst lines = Array.isArray(src.line_items) ? src.line_items.map(item => ({\n  sku: String(item.sku ?? '').trim(),\n  name: String(item.name ?? '').trim(),\n  quantity: Number(item.quantity ?? 0),\n  total: Number(item.total ?? 0)\n})) : [];\nreturn [{ json: {\n  action: topic.includes('deleted') ? 'ignore' : 'sync_order',\n  idempotency_key: `woocommerce:${shop}:${topic}:${orderId}`,\n  external_order_id: `woocommerce:${shop}:${orderId}`,\n  order_id: orderId,\n  order_number: String(src.number ?? orderId),\n  status: String(src.status ?? '').trim(),\n  total: Number(src.total ?? 0),\n  currency: String(src.currency ?? '').trim(),\n  customer_email: email,\n  customer_phone: phone,\n  shipping_city: String(src.shipping?.city ?? '').trim(),\n  line_items: lines,\n  crm_comment: `WooCommerce order ${src.number ?? orderId}, status=${src.status ?? 'unknown'}`\n}}];"
      },
      "id": "1c8fd3b3-0a27-4e07-a2eb-fbee1d275103",
      "name": "Normalize WooCommerce order",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst headers = $json.headers ?? {};\nconst topic = String(headers['x-wc-webhook-topic'] ?? src.topic ?? 'order.updated').trim();\nconst shop = String(src.shop_domain ?? headers.host ?? 'woocommerce').trim().toLowerCase();\nconst orderId = String(src.id ?? '').trim();\nif (!orderId) throw new Error('No WooCommerce order id');\nconst email = String(src.billing?.email ?? '').trim().toLowerCase();\nconst phone = String(src.billing?.phone ?? '').trim();\nconst lines = Array.isArray(src.line_items) ? src.line_items.map(item => ({\n  sku: String(item.sku ?? '').trim(),\n  name: String(item.name ?? '').trim(),\n  quantity: Number(item.quantity ?? 0),\n  total: Number(item.total ?? 0)\n})) : [];\nreturn [{ json: {\n  action: topic.includes('deleted') ? 'ignore' : 'sync_order',\n  idempotency_key: `woocommerce:${shop}:${topic}:${orderId}`,\n  external_order_id: `woocommerce:${shop}:${orderId}`,\n  order_id: orderId,\n  order_number: String(src.number ?? orderId),\n  status: String(src.status ?? '').trim(),\n  total: Number(src.total ?? 0),\n  currency: String(src.currency ?? '').trim(),\n  customer_email: email,\n  customer_phone: phone,\n  shipping_city: String(src.shipping?.city ?? '').trim(),\n  line_items: lines,\n  crm_comment: `WooCommerce order ${src.number ?? orderId}, status=${src.status ?? 'unknown'}`\n}}];"
      },
      "id": "08bb7ce9-22e4-4625-92e9-e15f5d2dd6a6",
      "name": "Build idempotency key",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "65b991ee-e99b-401c-af43-003b276e9e5f",
      "name": "Find order in CRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "0ae9056f-b2e9-4241-92d2-5235fdcd5dc3",
      "name": "Create or update order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "fc46b0ae-0f01-4a18-8c61-dc7cef6e814a",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    }
  ],
  "connections": {
    "WooCommerce Webhook": {
      "main": [
        [
          {
            "node": "Normalize WooCommerce order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize WooCommerce order": {
      "main": [
        [
          {
            "node": "Build idempotency key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build idempotency key": {
      "main": [
        [
          {
            "node": "Find order in CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find order in CRM": {
      "main": [
        [
          {
            "node": "Create or update order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update order": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "integration",
    "production"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "15f17514-43c2-4e3c-bdaa-353802bef055",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}