{
  "nodes": [
    {
      "parameters": {
        "path": "shopify-rag",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "Webhook",
      "name": "Shopify Webhook Listener",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [200, 300]
    },
    // Enhanced Data Aggregation
    {
      "parameters": {
        "operation": "getAll",
        "returnAll": true,
        "options": {
          "include": "orders,customers,products,inventory"
        }
      },
      "id": "Shopify Full Sync",
      "name": "Shopify Full Sync",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [400, 300]
    },
    // Behavioral Analytics Integration
    {
      "parameters": {
        "url": "https://api.segment.io/v1/export",
        "method": "POST",
        "bodyParametersUi": {
          "parameter": [
            {"name": "userId", "value": "={{ $json['customer']['id'] }}"},
            {"name": "events", "value": "={{ $json['behavior'] }}"}
          ]
        }
      },
      "id": "Behavioral Tracking",
      "name": "Behavioral Tracking",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [600, 300]
    },
    // Multi-Modal Embedding Generator
    {
      "parameters": {
        "url": "https://api.openai.com/v1/embeddings",
        "method": "POST",
        "bodyParametersUi": {
          "parameter": [
            {"name": "input", "value": "Product: {{ $json['title'] }}\nDescription: {{ $json['body_html'] }}\nImages: {{ $json['images']|map(attribute='src')|join(', ') }}"},
            {"name": "model", "value": "text-embedding-3-large"}
          ]
        }
      },
      "id": "Multi-Modal Embeddings",
      "name": "Multi-Modal Embeddings",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [800, 300]
    },
    // Real-Time Inventory Check
    {
      "parameters": {
        "operation": "get",
        "resource": "inventoryLevel",
        "locationIds": ["gid://shopify/Location/123456"],
        "options": {}
      },
      "id": "Inventory Check",
      "name": "Inventory Check",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [1000, 300]
    },
    // Dynamic Pricing Engine
    {
      "parameters": {
        "functionCode": "const demand = $json['sales_velocity'];\nconst compPrice = $json['competitor_price'];\nreturn [{ json: { price: demand > 0.8 ? compPrice * 0.95 : compPrice * 1.1 } }];"
      },
      "id": "Pricing Strategy",
      "name": "Pricing Strategy",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [1200, 300]
    },
    // Personalized Content Generator
    {
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "bodyParametersUi": {
          "parameter": [
            {"name": "model", "value": "gpt-4-turbo"},
            {"name": "messages", "value": "[{\"role\":\"system\",\"content\":\"Generate personalized content for {{ $json['customer']['firstName'] }} based on: Purchase history: {{ $json['order_history']|map(attribute='total_price')|join(', ') }}, Browsing behavior: {{ $json['browsing_history']|slice(0,3) }}, Inventory status: {{ $json['inventory'] }}\"}]"}
          ]
        }
      },
      "id": "AI Content Engine",
      "name": "AI Content Engine",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1400, 300]
    },
    // Omnichannel Delivery
    {
      "parameters": {
        "operation": "create",
        "resource": "draftOrder",
        "options": {
          "lineItems": "={{ $json['recommendations']|map(item => { product_id: item.id }) }}",
          "customer": "={{ $json['customer'] }}"
        }
      },
      "id": "Shopify Order Draft",
      "name": "Shopify Order Draft",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [1600, 300]
    }
  ],
  "connections": {
    "Webhook": {"main": [[{"node": "Shopify Full Sync", "type": "main", "index": 0}]]},
    "Shopify Full Sync": {"main": [[{"node": "Behavioral Tracking", "type": "main", "index": 0}]]},
    "Behavioral Tracking": {"main": [[{"node": "Multi-Modal Embeddings", "type": "main", "index": 0}]]},
    "Multi-Modal Embeddings": {"main": [[{"node": "Inventory Check", "type": "main", "index": 0}]]},
    "Inventory Check": {"main": [[{"node": "Pricing Strategy", "type": "main", "index": 0}]]},
    "Pricing Strategy": {"main": [[{"node": "AI Content Engine", "type": "main", "index": 0}]]},
    "AI Content Engine": {"main": [[{"node": "Shopify Order Draft", "type": "main", "index": 0}]]}
  }
}
