{
  "name": "ProofLab — Telegram + OpenAI approval sandbox",
  "nodes": [
    {
      "parameters": {
        "content": "## ProofLab sandbox\nSelf-initiated workflow — not client work.\n\nSafe by default:\n- workflow is inactive after import;\n- no credentials are embedded;\n- OpenAI and Telegram nodes are disabled;\n- the active branch returns a mock draft only.\n\nBefore production: configure credentials, validate the payload schema, add rate/budget limits, and keep the human approval gate.",
        "height": 340,
        "width": 430,
        "color": 5
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69001",
      "name": "READ ME FIRST",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-760, -300]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "prooflab-content-draft",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69002",
      "name": "Draft Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [-440, 80],
      "webhookId": "prooflab-content-draft"
    },
    {
      "parameters": {
        "jsCode": "const body = $json.body ?? $json;\nconst topic = String(body.topic ?? 'Нова послуга').slice(0, 120);\nconst approved = body.approved === true;\nreturn [{ json: { topic, approved, source: 'prooflab-sandbox', receivedAt: new Date().toISOString() } }];"
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69003",
      "name": "Normalize + Limit",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [-200, 80]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, draft: `Чернетка для теми «${$json.topic}». Перевірте факти, тон і посилання перед публікацією.`, model: 'sandbox-mock', externalCall: false } }];"
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69004",
      "name": "Sandbox Draft",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [40, 80]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [
            {
              "id": "approval-condition",
              "leftValue": "={{ $json.approved }}",
              "rightValue": true,
              "operator": { "type": "boolean", "operation": "true", "singleValue": true }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69005",
      "name": "Human Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [280, 80]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ok: false, status: 'awaiting_human_approval', draft: $json.draft, externalCall: false } }];"
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69006",
      "name": "Await Approval",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [520, 180]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ok: true, status: 'approved_sandbox', draft: $json.draft, note: 'Telegram publish remains disabled until credentials and channel permissions are configured.' } }];"
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69007",
      "name": "Safe Publish Placeholder",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [520, -20]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69008",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [780, 80]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/responses",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "=Bearer {{ $env.OPENAI_API_KEY }}" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={\"model\":\"gpt-5.6\",\"input\":{{ JSON.stringify($json.topic) }}}",
        "options": {}
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69009",
      "name": "OpenAI Responses API — DISABLED",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [20, -220],
      "disabled": true
    },
    {
      "parameters": {
        "chatId": "REPLACE_WITH_CHANNEL_ID",
        "text": "={{ $json.draft }}",
        "additionalFields": {}
      },
      "id": "aab9e7b5-7fa2-4b07-bef5-4c5323a69010",
      "name": "Telegram Send — DISABLED",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [520, -220],
      "disabled": true
    }
  ],
  "pinData": {},
  "connections": {
    "Draft Webhook": { "main": [[{ "node": "Normalize + Limit", "type": "main", "index": 0 }]] },
    "Normalize + Limit": { "main": [[{ "node": "Sandbox Draft", "type": "main", "index": 0 }]] },
    "Sandbox Draft": { "main": [[{ "node": "Human Approved?", "type": "main", "index": 0 }]] },
    "Human Approved?": {
      "main": [
        [{ "node": "Safe Publish Placeholder", "type": "main", "index": 0 }],
        [{ "node": "Await Approval", "type": "main", "index": 0 }]
      ]
    },
    "Safe Publish Placeholder": { "main": [[{ "node": "Webhook Response", "type": "main", "index": 0 }]] },
    "Await Approval": { "main": [[{ "node": "Webhook Response", "type": "main", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "versionId": "aab9e7b5-7fa2-4b07-bef5-4c5323a69999",
  "meta": { "templateCredsSetupCompleted": false },
  "tags": []
}
