{
  "name": "bmw-simulate-endpoint",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "simulate",
        "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: 2500, system: 'You are the Scenario Simulator Agent for the BMW Executive Hiring Advisor. \\nYour role is to read the latest internal company news/memos (from the BMW intranet HTML) and evaluate how a specific executive candidate would likely react and handle each strategic development.\\n\\nYou will receive:\\n1. INTRANET HTML: The raw HTML of the internal news portal\\n2. CANDIDATE DOSSIER: The candidate\\'s background, traits, and past feedback\\n3. STRUCTURAL BRIEF: The organizational constraints and rules\\n4. CANDIDATE NAME: The name of the candidate being evaluated\\n\\nYOUR TASK:\\n1. Extract 2 to 3 distinct strategic news items or signals from the Intranet HTML.\\n2. For each news item, synthesize a realistic \"simulation\" of how the candidate will react based strictly on their dossier and the structural brief.\\n3. Categorize the signal as \"Positive\" (a tailwind for their strengths), \"Concern\" (a headwind or risk area), or \"Neutral\".\\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  \"simulations\": [\\n    {\\n       \"news_headline\": \"The exact or summarized headline of the news item\",\\n       \"signal\": \"Positive\" | \"Concern\" | \"Neutral\",\\n       \"source\": \"E.g. CFO Memo, Internal Blog, Strategy Update\",\\n       \"date\": \"Date mentioned in the news item, or \\'Recent\\' if none\",\\n       \"strategic_relevance\": \"1-2 sentences on why this news matters to the firm\",\\n       \"candidate_name\": \"The candidate\\'s name\",\\n       \"likely_reaction\": \"A detailed 2-3 sentence projection of the candidate\\'s initial reaction and first move.\",\\n       \"relevant_background\": \"What specific part of their dossier informs this reaction?\",\\n       \"pros\": [\\n         \"Why their reaction is effective\",\\n         \"A key strength they will leverage\"\\n       ],\\n       \"cons\": [\\n         \"A risk in their approach\",\\n         \"A blind spot or potential friction point\"\\n       ],\\n       \"signal_reasoning\": \"A 1-2 sentence concluding summary of this match.\"\\n    }\\n  ]\\n}\\n\\n---\\n\\nANTI-INSTRUCTIONS (WHAT NOT TO DO):\\n- DO NOT invent news items. Only use signals found in the INTRANET HTML.\\n- DO NOT use generic HR speak. Instead, reference specific behaviors.\\n- DO NOT evaluate the candidate in a vacuum. Connect them explicitly to the structural constraints provided.\\n- DO NOT return anything outside of the JSON structure.', messages: [{ role: 'user', content: 'INTRANET HTML:\\n' + $('Webhook').first().json.body.intranet_html + '\\n\\nCANDIDATE DOSSIER:\\n' + $('Webhook').first().json.body.candidate_text + '\\n\\nSTRUCTURAL BRIEF:\\n' + $('Webhook').first().json.body.structural_text + '\\n\\nCANDIDATE NAME:\\n' + $('Webhook').first().json.body.candidate_name }] }) }}"
      },
      "id": "simulate-agent",
      "name": "Simulate 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;\n\n// Handle HTTP Request response format\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-simulate",
      "name": "Parse Simulate Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($('Parse Simulate 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": "Simulate Agent API Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simulate Agent API Call": {
      "main": [
        [
          {
            "node": "Parse Simulate Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Simulate Output": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "bmw-hackathon"
    }
  ]
}