{
  "name": "Clara Pipeline B - Onboarding to v2",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger-1",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "account_id",
              "value": "ACC_001"
            }
          ]
        }
      },
      "id": "set-1",
      "name": "Set Account ID",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "command": "python /scripts/patch.py --v1-memo /outputs/accounts/{{ $json.account_id }}/v1/account_memo.json --onboarding-dir /inputs/{{ $json.account_id }}_onboarding --output /outputs/accounts/{{ $json.account_id }}/v2"
      },
      "id": "exec-1",
      "name": "Run Pipeline B",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "command": "python /scripts/generate_spec.py --memo /outputs/accounts/{{ $json.account_id }}/v2/account_memo.json --output /outputs/accounts/{{ $json.account_id }}/v2/agent_spec.json --version v2"
      },
      "id": "exec-2",
      "name": "Generate v2 Spec",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "https://api.retell.ai/update-agent/{{ $json.agent_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "json",
        "body": "={{ JSON.stringify({ \"voice_id\": \"11labs-Adrian\", \"language\": \"en-US\", \"general_prompt\": $json.system_prompt }) }}"
      },
      "id": "http-1",
      "name": "Update Retell Agent",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.github.com/repos/{{ $env.GITHUB_REPO }}/issues/{{ $json.issue_number }}/comments",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "json",
        "body": "={{ JSON.stringify({ \"body\": \"## v2 Update \u2014 Onboarding Complete\\n\\nUpdated: \" + new Date().toISOString() + \"\\n\\n### Changes Applied\\n\\nv2 configuration has been generated from onboarding call.\\n\\n---\\nPipeline B complete \u2705\" }) }}"
      },
      "id": "http-2",
      "name": "Add GitHub Comment",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "v2_updated"
            }
          ]
        }
      },
      "id": "set-2",
      "name": "Set Complete Status",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1450,
        300
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Set Account ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Account ID": {
      "main": [
        [
          {
            "node": "Run Pipeline B",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Pipeline B": {
      "main": [
        [
          {
            "node": "Generate v2 Spec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate v2 Spec": {
      "main": [
        [
          {
            "node": "Update Retell Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Retell Agent": {
      "main": [
        [
          {
            "node": "Add GitHub Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add GitHub Comment": {
      "main": [
        [
          {
            "node": "Set Complete Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}