{
  "name": "Ship Lean - n8n AI Agent Human Approval Pattern",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b9d72f-2d86-4f8c-bb95-2fb687227d4a",
      "name": "Manual test trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "request",
              "name": "request",
              "type": "string",
              "value": "Draft a public post from this build log"
            },
            {
              "id": "risk_level",
              "name": "risk_level",
              "type": "string",
              "value": "public"
            },
            {
              "id": "source_url",
              "name": "source_url",
              "type": "string",
              "value": "https://christopheralarcon.com/workflows/n8n-ai-agent-workflow"
            }
          ]
        },
        "options": {}
      },
      "id": "ea5f40bb-52d5-4205-83ab-76da35fd0f6f",
      "name": "Sample context",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [480, 300]
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\n\n// Replace this stub with an AI Agent node, Claude/OpenAI call, or your own scoring logic.\n// Keep the output structured so the rest of the workflow is boring and reliable.\nconst needsApproval = ['public', 'customer', 'money', 'legal'].includes(item.risk_level);\n\nreturn [{\n  json: {\n    ...item,\n    agent_decision: 'draft_ready_for_review',\n    needs_approval: needsApproval,\n    approval_reason: needsApproval ? 'Public or high-consequence action' : 'Internal/low-risk action',\n    next_step: needsApproval ? 'send_to_human_review' : 'route_to_output'\n  }\n}];"
      },
      "id": "b96d2a6f-c92e-4c38-8ad0-b5d7997f3e63",
      "name": "Agent decision stub",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [720, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "needs-approval",
              "leftValue": "={{ $json.needs_approval }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "2a0e4529-7d4b-4f9a-8aef-c8b753b77142",
      "name": "Needs human approval?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [960, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "status",
              "type": "string",
              "value": "waiting_for_human_approval"
            },
            {
              "id": "owner",
              "name": "owner",
              "type": "string",
              "value": "Chris"
            }
          ]
        },
        "options": {}
      },
      "id": "c9972ab7-df84-4d7e-99be-f8e0cb2587cb",
      "name": "Queue for approval",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1200, 180]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "status",
              "type": "string",
              "value": "approved_for_output_route"
            },
            {
              "id": "route",
              "name": "route",
              "type": "string",
              "value": "notion_or_publishing_queue"
            }
          ]
        },
        "options": {}
      },
      "id": "2b5fa6ed-26cc-4c15-9fd1-2ddc6fdf0767",
      "name": "Route low-risk output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1200, 420]
    }
  ],
  "connections": {
    "Manual test trigger": {
      "main": [
        [
          {
            "node": "Sample context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample context": {
      "main": [
        [
          {
            "node": "Agent decision stub",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent decision stub": {
      "main": [
        [
          {
            "node": "Needs human approval?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs human approval?": {
      "main": [
        [
          {
            "node": "Queue for approval",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Route low-risk output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": []
}
