{
  "name": "Thunder Manager Agent (Final)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "manager-agent",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Sen Thunder ERP'nin y\u00f6netici karar verme agent'\u0131s\u0131n.\n\nG\u00f6revlerin:\n1. Stratejik kararlar al\n2. \u00c7oklu agent konsens\u00fcs\u00fc olu\u015ftur\n3. Kritik onaylar\u0131 de\u011ferlendir\n4. Sistem performans\u0131n\u0131 analiz et\n5. \u0130\u015f s\u00fcre\u00e7lerini optimize et\n\nYan\u0131t format\u0131 JSON:\n{\n  \"decision\": \"approved\" | \"rejected\" | \"needs_review\",\n  \"reasoning\": \"Karar gerek\u00e7esi\",\n  \"manager_analysis\": {\n    \"consensus\": \"\",\n    \"risk_assessment\": {},\n    \"recommendations\": [],\n    \"approval_required\": false\n  },\n  \"confidence\": 0.95\n}"
            },
            {
              "role": "user",
              "content": "={{ $json.body.prompt }}"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxTokens": 2048
        },
        "simplifyOutput": true
      },
      "id": "openai-agent",
      "name": "Manager Agent (GPT-4o)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// OpenAI node'dan gelen response'u al\nconst input = $input.item.json;\n\n// Response format\u0131n\u0131 kontrol et ve content'i \u00e7\u0131kar\nlet content = '';\n\n// Input bir object ise (simplifyOutput: true oldu\u011funda)\nif (input.message && input.message.content) {\n  content = input.message.content;\n}\n// Input bir array ise\nelse if (Array.isArray(input) && input.length > 0) {\n  if (input[0].message && input[0].message.content) {\n    content = input[0].message.content;\n  } else if (input[0].content) {\n    content = input[0].content;\n  } else {\n    content = JSON.stringify(input[0]);\n  }\n}\n// Di\u011fer formatlar\nelse if (input.content) {\n  content = input.content;\n} else {\n  // Fallback: t\u00fcm input'u string'e \u00e7evir\n  content = JSON.stringify(input);\n}\n\n// Response olu\u015ftur\nconst response = {\n  success: true,\n  agent: \"manager\",\n  response: content\n};\n\nreturn {\n  json: response\n};"
      },
      "id": "code-node",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "id": "response",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Manager Agent (GPT-4o)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manager Agent (GPT-4o)": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "updatedAt": "2025-01-27T00:00:00.000Z",
  "versionId": "1"
}