{
  "name": "bmw-search-endpoint",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "search",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.anthropic.com/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            },
            {
              "name": "content-type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={{ JSON.stringify({ model: 'claude-sonnet-4-20250514', max_tokens: 3000, system: \"You are the specialized Headhunter AI for the BMW Group Executive Hiring Advisor.\\n\\nYour job is to read an internal Job Title and Job Description, and immediately hallucinate and dynamically generate 3 to 5 highly realistic, unique candidates who could fill that role.\\n\\nThese candidates must be extremely BMW-contextualized. Ensure you mix internal hires (e.g. \\\"Head of Lean Production at Munich\\\", \\\"Plant Controller at Dingolfing\\\") and external industry hires (e.g. \\\"Former Tesla Gigafactory Lead\\\", \\\"Supply Chain VP at Bosch\\\").\\n\\nYou will receive:\\n1. JOB TITLE\\n2. JOB DESCRIPTION\\n3. (Optional) SUGGESTED NAMES to prioritize or include as easter eggs.\\n\\nFor each candidate, give them distinct leadership traits, plausible German/Global automotive backgrounds, realistic KPI scores (0-100), and a 6-quarter performance/engagement history mapping out their recent trajectory.\\n\\n---\\n\\nOUTPUT FORMAT:\\nYou must return your analysis STRICTLY as a JSON object matching the schema below.\\nDO NOT wrap the JSON in markdown code blocks. DO NOT output any text before or after the JSON.\\n\\n{\\n  \\\"candidates\\\": [\\n    {\\n       \\\"id\\\": \\\"A unique integer, e.g., 1, 2, 3\\\",\\n       \\\"name\\\": \\\"First Name + Last Initial (e.g. 'Markus W.')\\\",\\n       \\\"role\\\": \\\"Current highly specific role\\\",\\n       \\\"department\\\": \\\"Current division/company (e.g., 'EV Manufacturing \u2014 Leipzig' or 'Supplier Network \u2014 Magna Steyr')\\\",\\n       \\\"matchScore\\\": \\\"An integer 60-99 representing how well they hypothetically fit the Job Desc\\\",\\n       \\\"avatar\\\": \\\"Their initials (e.g., 'MW')\\\",\\n       \\\"kpis\\\": {\\n         \\\"decisionSpeed\\\": 0-100,\\n         \\\"changeTolerance\\\": 0-100,\\n         \\\"financialDepth\\\": 0-100,\\n         \\\"evLiteracy\\\": 0-100,\\n         \\\"psychSafety\\\": 0-100,\\n         \\\"leadership\\\": 0-100,\\n         \\\"technicalSkill\\\": 0-100,\\n         \\\"communication\\\": 0-100\\n       },\\n       \\\"history\\\": [\\n         { \\\"quarter\\\": \\\"Q1 24\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 },\\n         { \\\"quarter\\\": \\\"Q2 24\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 },\\n         { \\\"quarter\\\": \\\"Q3 24\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 },\\n         { \\\"quarter\\\": \\\"Q4 24\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 },\\n         { \\\"quarter\\\": \\\"Q1 25\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 },\\n         { \\\"quarter\\\": \\\"Q2 25\\\", \\\"performance\\\": 0-100, \\\"engagement\\\": 0-100 }\\n       ],\\n       \\\"summary\\\": \\\"A 2-3 sentence highly specific narrative summary of their background, their core strengths, and what they are known for (e.g., 'Led the EBIT recovery programme restoring 3.4pp margin...')\\\"\\n    }\\n  ]\\n}\\n\\nANTI-INSTRUCTIONS:\\n- DO NOT use generic HR jargon. Use automotive/manufacturing/financial terminology appropriate for BMW.\\n- DO NOT return anything outside of the JSON structure.\", messages: [{ role: 'user', content: 'JOB TITLE:\\n' + $('Webhook').first().json.body.job_name + '\\n\\nJOB DESCRIPTION:\\n' + $('Webhook').first().json.body.job_description + '\\n\\nSUGGESTED NAMES:\\n' + ($('Webhook').first().json.body.suggested_names || 'None') }] }) }}"
      },
      "id": "search-agent",
      "name": "Search Agent API Call",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json;\nlet text = '';\nif (input.content && Array.isArray(input.content)) {\n  text = input.content[0].text || '';\n} else {\n  text = input.text || input.response?.text || input.output || '';\n}\n\nconst jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\nif (!jsonMatch) {\n  return [{ json: { parse_error: true, raw_response: text.substring(0, 500) } }];\n}\n\ntry {\n  const parsed = JSON.parse(jsonMatch[0]);\n  return [{ json: parsed }];\n} catch (e) {\n  return [{ json: { parse_error: true, raw_response: text.substring(0, 500), error: e.message } }];\n}"
      },
      "id": "parse-search",
      "name": "Parse Search Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($('Parse Search Output').first().json) }}",
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              },
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              },
              {
                "name": "Access-Control-Allow-Headers",
                "value": "Content-Type"
              },
              {
                "name": "Access-Control-Allow-Methods",
                "value": "POST, OPTIONS"
              }
            ]
          }
        }
      },
      "id": "respond-to-webhook",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        960,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Search Agent API Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Agent API Call": {
      "main": [
        [
          {
            "node": "Parse Search Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Search Output": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "bmw-hackathon"
    }
  ]
}