{
  "name": "Needs Review Workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "needs-review",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "e706c602-6d1f-45ce-8161-b60a2ccd4eb9",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        -1008,
        112
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "orderId",
              "value": "={{ $json.body.orderId }}"
            },
            {
              "name": "validationIssues",
              "value": "={{ JSON.stringify($json.body.orderData.validation.issues) }}"
            },
            {
              "name": "customerEmail",
              "value": "={{ $json.body.orderData.customerEmail }}"
            },
            {
              "name": "csrEmail",
              "value": "csr@printcompany.com"
            }
          ]
        },
        "options": {}
      },
      "id": "6310b256-8a51-4f9c-a6a7-a1fdabd4c4c5",
      "name": "Set Variables",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -800,
        112
      ]
    },
    {
      "parameters": {
        "fromEmail": "email.verify.921@gmail.com",
        "toEmail": "uditgoyaludit0@gmail.com",
        "subject": "=Order Needs Review - {{ $json.body.orderId }}",
        "options": {}
      },
      "id": "03fda4ba-e5b8-4cf4-a68e-0571de259458",
      "name": "Notify CSR",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        -608,
        112
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "options": {}
      },
      "id": "d68ed04f-da53-4593-aa7f-3dc6fd19ef96",
      "name": "Wait for CSR Decision",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        -400,
        112
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.body.csrAction }}",
              "operation": "contains",
              "value2": "approved"
            }
          ]
        }
      },
      "id": "45d6411c-a41a-4db6-911e-9327e4c5757a",
      "name": "Check CSR Decision",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -208,
        112
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "=http://backend:3000/api/v1/orders/{{ $json.body.orderId }}/approve",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{ JSON.stringify({ approver: $json.body.csrName, notes: $json.body.csrNotes }) }}"
      },
      "id": "b466740d-c2a2-44f3-a4e6-440d88b53692",
      "name": "Approve Order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.body.csrAction }}",
              "operation": "contains",
              "value2": "quote_adjustment"
            }
          ]
        }
      },
      "id": "3e0c5349-41de-40d6-824b-69893727aed2",
      "name": "Check Quote Adjustment",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        0,
        112
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "=http://backend:3000/api/v1/orders/{{ $json.body.orderId }}/price",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {}
      },
      "id": "542777ab-643e-4e10-86ed-ca64afcb0f4b",
      "name": "Recalculate Pricing",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        208,
        112
      ]
    },
    {
      "parameters": {
        "fromEmail": "email.verify.921@gmail.com",
        "toEmail": "={{ $json.body.orderData.customerEmail }}",
        "subject": "Order Update - {{ $json.body.orderId }}",
        "options": {}
      },
      "id": "38aee5f2-d429-4538-a662-1d62e4450680",
      "name": "Notify Customer",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        208,
        0
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, message: 'Workflow started', resumeUrl: $execution.resumeUrl, orderId: $json.body.orderId }) }}",
        "options": {}
      },
      "id": "b42a1f2a-55d3-4a51-ad36-c7a807807f68",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        -800,
        304
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "=http://backend:3000/api/v1/orders/{{ $json.body.orderId }}/reject",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {}
      },
      "id": "fbdbf81f-d0c7-4087-8bd8-36a73225c56a",
      "name": "Reject Order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        0,
        208
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Set Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Variables": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Response": {
      "main": [
        [
          {
            "node": "Notify CSR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify CSR": {
      "main": [
        [
          {
            "node": "Wait for CSR Decision",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for CSR Decision": {
      "main": [
        [
          {
            "node": "Check CSR Decision",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check CSR Decision": {
      "main": [
        [
          {
            "node": "Approve Order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Quote Adjustment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve Order": {
      "main": [
        [
          {
            "node": "Notify Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Quote Adjustment": {
      "main": [
        [
          {
            "node": "Recalculate Pricing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reject Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "e9ce86fc-ee24-4afc-a02a-bfa9ce451293",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "RPVtM7wpRkt8YsdrROV5g",
  "tags": []
}