{
  "name": "E-commerce Order Processing Workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "order-webhook",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "order-webhook-trigger",
      "name": "Order Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [240, 300],
      "webhookId": "ecommerce-order-processing"
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.orderId }}",
              "operation": "notEmpty"
            },
            {
              "value1": "={{ $json.status }}",
              "value2": "completed",
              "operation": "equal"
            }
          ]
        }
      },
      "id": "validate-order",
      "name": "Validate Order",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "resource": "order",
        "operation": "get",
        "orderId": "={{ $json.orderId }}"
      },
      "id": "get-order-details",
      "name": "Get Order Details",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [680, 200],
      "credentials": {
        "shopifyApi": {
          "id": "shopify-credentials",
          "name": "Shopify API"
        }
      }
    },
    {
      "parameters": {
        "resource": "inventory",
        "operation": "update",
        "productId": "={{ $json.line_items[0].product_id }}",
        "additionalFields": {
          "quantity": "={{ $json.line_items[0].quantity }}",
          "operation": "decrease"
        }
      },
      "id": "update-inventory",
      "name": "Update Inventory",
      "type": "n8n-nodes-base.shopify",
      "typeVersion": 1,
      "position": [900, 200],
      "credentials": {
        "shopifyApi": {
          "id": "shopify-credentials",
          "name": "Shopify API"
        }
      }
    },
    {
      "parameters": {
        "resource": "email",
        "operation": "send",
        "additionalFields": {
          "to": "={{ $json.email }}",
          "subject": "Order Confirmation - #{{ $json.orderId }}",
          "html": "<h1>Order Confirmed!</h1><p>Your order #{{ $json.orderId }} has been confirmed and is being processed.</p>",
          "from": "orders@company.com"
        }
      },
      "id": "send-order-confirmation",
      "name": "Send Order Confirmation",
      "type": "n8n-nodes-base.sendGrid",
      "typeVersion": 1,
      "position": [1120, 200],
      "credentials": {
        "sendGridApi": {
          "id": "sendgrid-credentials",
          "name": "SendGrid API"
        }
      }
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "create",
        "additionalFields": {
          "email": "={{ $json.email }}",
          "firstName": "={{ $json.firstName || '' }}",
          "lastName": "={{ $json.lastName || '' }}",
          "tags": "={{ ['customer', 'order-completed'] }}",
          "properties": {
            "total_spent": "={{ $json.total_price }}",
            "order_count": "1"
          }
        }
      },
      "id": "update-crm",
      "name": "Update CRM",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 1,
      "position": [1120, 400],
      "credentials": {
        "hubspotApi": {
          "id": "hubspot-credentials",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "create",
        "additionalFields": {
          "title": "Process order #{{ $json.orderId }}",
          "description": "New order received from {{ $json.email }}",
          "due_date": "={{ $now.plus({ hours: 2 }).toISOString() }}",
          "assignee": "fulfillment-team"
        }
      },
      "id": "create-fulfillment-task",
      "name": "Create Fulfillment Task",
      "type": "n8n-nodes-base.asana",
      "typeVersion": 1,
      "position": [1340, 300],
      "credentials": {
        "asanaApi": {
          "id": "asana-credentials",
          "name": "Asana API"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "channel": "orders",
        "additionalFields": {
          "text": "New order #{{ $json.orderId }} received from {{ $json.email }} - Total: ${{ $json.total_price }}"
        }
      },
      "id": "notify-slack",
      "name": "Notify Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [1340, 500],
      "credentials": {
        "slackApi": {
          "id": "slack-credentials",
          "name": "Slack API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.orderId }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "id": "handle-invalid-order",
      "name": "Handle Invalid Order",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [680, 400]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"error\": \"Order ID is required\",\n  \"status\": \"failed\"\n}",
        "options": {}
      },
      "id": "error-response",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [900, 400]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"message\": \"Order processed successfully\",\n  \"status\": \"success\",\n  \"orderId\": \"{{ $json.orderId }}\"\n}",
        "options": {}
      },
      "id": "success-response",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1560, 300]
    }
  ],
  "connections": {
    "Order Webhook Trigger": {
      "main": [
        [
          {
            "node": "Validate Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Order": {
      "main": [
        [
          {
            "node": "Get Order Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Invalid Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Order Details": {
      "main": [
        [
          {
            "node": "Update Inventory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Inventory": {
      "main": [
        [
          {
            "node": "Send Order Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Order Confirmation": {
      "main": [
        [
          {
            "node": "Update CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update CRM": {
      "main": [
        [
          {
            "node": "Create Fulfillment Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Fulfillment Task": {
      "main": [
        [
          {
            "node": "Notify Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Slack": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Invalid Order": {
      "main": [
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "createdAt": "2025-01-01T00:00:00.000Z",
      "updatedAt": "2025-01-01T00:00:00.000Z",
      "id": "ecommerce",
      "name": "E-commerce"
    }
  ],
  "triggerCount": 1,
  "updatedAt": "2025-01-01T00:00:00.000Z",
  "versionId": "1.0.0"
}

