{
  "name": "News Agent Webhook",
  "nodes": [
    {
      "parameters": {
        "path": "news-analyze",
        "options": {
          "responseData": "={{$json}}"
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        200,
        300
      ],
      "name": "Webhook"
    },
    {
      "parameters": {
        "propertyName": "stage",
        "switchCases": {
          "preprocess": 1,
          "postprocess": 2
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        420,
        300
      ],
      "name": "Switch Stage"
    },
    {
      "parameters": {
        "functionCode": "const input = items[0].json.input || {};\nlet text = input.text || '';\nif (input.url) {\n  if (input.url.includes('news.naver.com')) {\n    // \ub124\uc774\ubc84 \ub274\uc2a4 \uc804\uc6a9 Selector\n    text = $json.body?.match(/<div[^>]*id=\\\"dic_area[\\\"]?[^>]*>([\\s\\S]*?)<\\/div>/)?.[1] || '';\n  } else {\n    text = text || `Fetched content from ${input.url}`;\n  }\n}\nreturn [{ json: { text } }];"
      },
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        200
      ],
      "name": "Preprocess Function"
    },
    {
      "parameters": {
        "functionCode": "const r = items[0].json.result;\nconst meta = { tokens: 0, model: 'mcp-provider', latencyMs: 0 };\nreturn [{ json: { ...r, meta } }];"
      },
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        400
      ],
      "name": "Postprocess Function"
    }
  ],
  "connections": {
    "Switch Stage": {
      "main": [
        [
          {
            "node": "Preprocess Function",
            "type": "main",
            "index": 0
          },
          {
            "node": "Postprocess Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Switch Stage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}