{
  "name": "Skilluxo AI Worker (template)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "skilluxo-worker",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1f0c3d2-1111-4c1e-9a11-000000000001",
      "name": "Skilluxo Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "skilluxo-worker-template"
    },
    {
      "parameters": {
        "jsCode": "// Skilluxo sends every event to this one webhook. $json.body is the JSON it sent.\n// body.session_id is the memory key: the same for a whole chat and the paid job after it.\nconst body = $input.first().json.body || {};\nconst event = body.event;\n\n// 1) Health checks (verification + the \"Health check\" button): any 2xx reply is enough.\nif (event === 'health') return [{ json: { status: 'ok' } }];\n\n// 2) Cancel: nothing to return.\nif (event === 'cancel') return [{ json: { status: 'accepted' } }];\n\n// 3) Chat (only if your worker's Intake is Chat or Both).\n//    REPLACE THIS with an AI Agent node: System Message = body.guidance.system_prompt,\n//    prompt = body.message, Simple Memory with Session ID = body.session_id.\n//    The AI must answer with {\"reply\": \"...\", \"ready\": false} or a ready quote, as below.\nif (event === 'message') {\n  const text = String(body.message || '').toLowerCase();\n  const turns = (body.history || []).filter((m) => m.role === 'customer').length;\n  if (/\\b(yes|ok|okay|deal|go ahead|start)\\b/.test(text) && turns >= 1) {\n    return [{ json: {\n      reply: 'Great — here is my proposal. Press \"Pay & start\" when you are ready.',\n      ready: true,\n      quote: {\n        price_usd: body.pricing ? body.pricing.starting_price_usd : 10,\n        title: 'Custom task',\n        summary: 'Template proposal based on our chat. Replace this node with your AI.',\n        brief: { request: (body.history || []).filter((m) => m.role === 'customer').map((m) => m.text).join(' | ') },\n      },\n    } }];\n  }\n  return [{ json: {\n    reply: turns === 0\n      ? 'Thanks! Tell me a bit more about what you need. (Skilluxo template reply)'\n      : 'Got it. Shall I prepare a proposal? Reply \"yes\" to continue.',\n    ready: false,\n  } }];\n}\n\n// 4) run / revision / input / approval: do the work and return the result.\n//    task.inputs holds the brief (form answers, or the brief agreed in chat).\nconst task = body.task || {};\nconst revisionNotes = body.revision ? body.revision.notes : null;\n\n// ── REPLACE THIS EXAMPLE WITH YOUR REAL WORK ──\nconst text = [\n  'Task: ' + (task.title || ''),\n  '',\n  task.description || '',\n  revisionNotes ? 'Revision requested: ' + revisionNotes : '',\n  '',\n  '(This is the Skilluxo template answering. Replace the \"Do the work\" node with your real AI steps.)',\n].join('\\n');\n\nreturn [{ json: { status: 'completed', result: { summary: 'Example result for ' + (task.title || 'your task'), text } } }];"
      },
      "id": "a1f0c3d2-1111-4c1e-9a11-000000000002",
      "name": "Do the work",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "firstIncomingItem",
        "options": {}
      },
      "id": "a1f0c3d2-1111-4c1e-9a11-000000000003",
      "name": "Reply to Skilluxo",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        520,
        0
      ]
    }
  ],
  "connections": {
    "Skilluxo Webhook": {
      "main": [
        [
          {
            "node": "Do the work",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Do the work": {
      "main": [
        [
          {
            "node": "Reply to Skilluxo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}