{
  "name": "ClaraAI - Pipeline V1 (Demo Call)",
  "nodes": [
    {
      "id": "v1-01",
      "name": "Form - Start V1",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "formTitle": "ClaraAI - New Account Setup (V1 Demo Call)",
        "formDescription": "Enter the account name and upload the demo/sales call recording.",
        "path": "clara-pipeline-v1",
        "responseMode": "lastNode",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Account Name",
              "fieldType": "text",
              "placeholder": "e.g. Ben's Electric Solutions",
              "requiredField": true
            },
            {
              "fieldLabel": "Demo Video",
              "fieldType": "file",
              "requiredField": true,
              "acceptFileTypes": ".mp4,.mov,.avi,.webm,.m4v,.mkv,.m4a,.mp3"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "v1-02",
      "name": "Save Video",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const fs   = require('fs');\nconst path = require('path');\n\nconst ROOT        = 'C:/Users/Admin/OneDrive/Desktop/ClaraAi';\nconst PYTHON_EXE  = 'C:/Users/Admin/AppData/Local/Programs/Python/Python312/python.exe';\nconst SCRIPT_PATH = ROOT + '/scripts/pipeline.py';\n\nconst formJson    = $input.first().json;\nconst inputBinary = $input.first().binary || {};\n\nconst accountName = String(formJson['Account Name'] || '').trim();\nif (!accountName) throw new Error('Account Name is required.');\n\nconst accountId = accountName\n  .toLowerCase()\n  .replace(/[^a-z0-9\\s-]/g, '')\n  .trim()\n  .replace(/\\s+/g, '-');\nif (!accountId) throw new Error('Account Name must contain at least one letter or number.');\n\nconst videoKey = Object.keys(inputBinary)[0];\nif (!videoKey) throw new Error('No video file found. Please attach a video.');\n\nconst videoFile = inputBinary[videoKey];\nconst ext       = (path.extname(videoFile.fileName || 'demo.mp4').toLowerCase()) || '.mp4';\nconst videoPath = path.join(ROOT, 'dataset', accountId, 'demo' + ext);\n\nfs.mkdirSync(path.dirname(videoPath), { recursive: true });\nfs.writeFileSync(videoPath, Buffer.from(videoFile.data, 'base64'));\nconsole.log('Video saved: ' + videoPath);\n\nreturn [{ json: { accountId, accountName, ROOT, PYTHON_EXE, SCRIPT_PATH } }];"
      }
    },
    {
      "id": "v1-03",
      "name": "Run Pipeline V1",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        760,
        300
      ],
      "parameters": {
        "command": "={{ '\"' + $json.PYTHON_EXE + '\" \"' + $json.SCRIPT_PATH + '\" --account-id ' + $json.accountId + ' --version v1' }}"
      }
    },
    {
      "id": "v1-04",
      "name": "Done",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1020,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const c   = $('Save Video').first().json;\nconst out = $input.first().json;\nreturn [{ json: {\n  status:  'complete',\n  account: c.accountName,\n  message: 'V1 pipeline done for ' + c.accountName,\n  outputs: {\n    transcript: c.ROOT + '/outputs/accounts/' + c.accountId + '/v1/transcripts/demo.txt',\n    memo:       c.ROOT + '/outputs/accounts/' + c.accountId + '/v1/memo.json',\n    spec:       c.ROOT + '/outputs/accounts/' + c.accountId + '/v1/spec.json'\n  },\n  stdout: out.stdout || '',\n  stderr: out.stderr || ''\n} }];"
      }
    }
  ],
  "connections": {
    "Form - Start V1": {
      "main": [
        [
          {
            "node": "Save Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Video": {
      "main": [
        [
          {
            "node": "Run Pipeline V1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Pipeline V1": {
      "main": [
        [
          {
            "node": "Done",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  },
  "versionId": "clara-v1-simple"
}