{
  "name": "Clara AI - Demo to V1 Pipeline",
  "nodes": [
    {
      "parameters": {},
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://host.docker.internal:8000/api/process-demo",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { transcript_path: $json.query.transcript_path, account_id: $json.query.account_id || null } }}"
      },
      "id": "process-demo-api",
      "name": "Process Demo Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.success }}",
              "value2": true
            }
          ]
        }
      },
      "id": "check-success",
      "name": "Check Success",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "content": "## Demo Processing Complete!\n\n**Account ID:** {{ $json.account_id }}\n**Version:** {{ $json.version }}\n**Method:** {{ $json.extraction_method }}\n\n### Output Files\n- Account Memo: {{ $json.output_files.account_memo }}\n- Agent Spec: {{ $json.output_files.agent_spec }}\n\n### Questions/Unknowns\n{{ $json.questions_or_unknowns.join('\\n- ') }}",
        "displayName": "Success Notification"
      },
      "id": "success-note",
      "name": "Success Summary",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {
        "content": "## Demo Processing Failed!\n\n**Error:** {{ $json.error || 'Unknown error' }}\n\nPlease check the logs and try again.",
        "displayName": "Error Notification"
      },
      "id": "error-note",
      "name": "Error Summary",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        850,
        400
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Read transcript file from local filesystem\nconst fs = require('fs');\nconst path = require('path');\n\nconst items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n  const transcriptPath = item.json.transcript_path;\n  \n  if (!transcriptPath) {\n    results.push({ json: { error: 'No transcript_path provided' } });\n    continue;\n  }\n  \n  try {\n    const content = fs.readFileSync(transcriptPath, 'utf-8');\n    results.push({\n      json: {\n        transcript_path: transcriptPath,\n        transcript_content: content,\n        account_id: item.json.account_id || null\n      }\n    });\n  } catch (err) {\n    results.push({\n      json: {\n        error: `Failed to read file: ${err.message}`,\n        transcript_path: transcriptPath\n      }\n    });\n  }\n}\n\nreturn results;"
      },
      "id": "read-transcript",
      "name": "Read Transcript File",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        450
      ]
    },
    {
      "parameters": {
        "operation": "create",
        "title": "={{ 'Clara: Process Demo - ' + $json.account_id }}",
        "additionalFields": {
          "assignee": "",
          "dueDate": "",
          "projects": [],
          "notes": "={{ 'Processed demo transcript for account: ' + $json.account_id + '\\n\\nQuestions:\\n' + ($json.questions_or_unknowns || []).join('\\n- ') }}"
        }
      },
      "id": "create-task",
      "name": "Create Tracking Task",
      "type": "n8n-nodes-base.asana",
      "typeVersion": 1,
      "position": [
        1050,
        200
      ],
      "disabled": true,
      "notesInFlow": true,
      "notes": "Enable this node and configure Asana credentials to create tracking tasks"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.github.com/repos/YOUR_REPO/issues",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "githubApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Clara: Review Demo - ' + $json.account_id, body: '## Demo Processing Complete\\n\\n**Account:** ' + $json.account_id + '\\n**Questions:**\\n' + ($json.questions_or_unknowns || []).map(q => '- ' + q).join('\\n'), labels: ['clara-ai', 'demo-review'] }) }}"
      },
      "id": "create-github-issue",
      "name": "Create GitHub Issue",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1050,
        100
      ],
      "disabled": true,
      "notesInFlow": true,
      "notes": "Enable this node and configure GitHub credentials to create tracking issues"
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Process Demo Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Demo Transcript": {
      "main": [
        [
          {
            "node": "Check Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Success": {
      "main": [
        [
          {
            "node": "Success Summary",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Summary": {
      "main": [
        [
          {
            "node": "Create GitHub Issue",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Tracking Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "clara-ai"
    },
    {
      "name": "pipeline-a"
    }
  ]
}