{"id":"S2fxW8jbFIetu8Vi","meta":{"instanceId":"8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177","templateCredsSetupCompleted":true},"name":"AI-Powered n8n Workflow Architecture Decision Engine","tags":[],"nodes":[{"id":"d5997a32-7d1a-404a-a6c2-83fc4ff3bdaa","name":"Receive Problem Description via POST","type":"n8n-nodes-base.webhook","position":[-384,544],"webhookId":"af08511e-f5d9-44e3-8a2f-2482b5c3e4a0","parameters":{"path":"af08511e-f5d9-44e3-8a2f-2482b5c3e4a0","options":{},"httpMethod":"POST","responseMode":"responseNode"},"typeVersion":2.1},{"id":"b709e130-d9f0-4542-974f-f1c65b43e116","name":"Extract Request Body","type":"n8n-nodes-base.code","position":[-176,544],"parameters":{"jsCode":"// Get the first incoming item\nconst inputData = $input.first().json;\n\n// Return only the body\nreturn [\n {\n json: inputData.body\n }\n];"},"typeVersion":2},{"id":"8217efaf-8a7f-4e10-8f31-ca8415405eb6","name":"Multi-Agent Architecture Decision Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[32,544],"parameters":{"text":"=Analyze the following problem description and decide whether it requires a multi-agent workflow in n8n.\n\nIf it requires multi-agent architecture, design the agents with node types and reasons.\n\nIf it does not require multi-agent architecture, clearly state that and provide a simpler workflow instead.\n\nProblem Description:\n{{ $json.description }}","options":{"systemMessage":"=You are an n8n Multi-Agent Workflow Architect.\n\nYour job is to analyze a given problem description and decide whether it requires a multi-agent workflow or not.\n\nDecision Rules:\n1. If the problem involves multiple independent reasoning steps (classification, extraction, validation, risk scoring, decision making, routing, follow-ups), then design a multi-agent workflow.\n2. If the problem is simple (single-step logic, direct transformation, or basic automation), DO NOT design a multi-agent workflow.\n\nIf Multi-Agent is Required:\n- Clearly define:\n - Agent Name\n - Purpose\n - n8n Node Type\n - Why it is required\n- Keep explanations short and precise.\n- Provide logical flow order.\n\nIf Multi-Agent is NOT Required:\n- Clearly state: \"This does not require a multi-agent workflow.\"\n- Provide a simpler workflow logic.\n- List minimal required nodes.\n- Keep it concise.\n\nOutput Format:\n\nDecision: (Multi-Agent Required / Not Required)\n\nIf Required:\n1. Agent Name\n - Purpose:\n - Node:\n - Reason:\n\nWorkflow Flow:\nStep 1 →\nStep 2 →\nStep 3 →\n\nIf Not Required:\nSimplified Workflow:\n- Node 1:\n- Node 2:\n- Node 3:\n\nBe precise. No long explanations."},"promptType":"define"},"typeVersion":3},{"id":"9b3114b1-6179-45de-9f0c-ac9ced81ed5c","name":"Azure OpenAI GPT-4o-mini","type":"@n8n/n8n-nodes-langchain.lmChatAzureOpenAi","position":[32,976],"parameters":{"model":"gpt-4o-mini","options":{}},"credentials":{"azureOpenAiApi":{"id":"C3WzT18XqF8OdVM6","name":"Azure Open AI account"}},"typeVersion":1},{"id":"f368874a-c30a-4a57-85ae-b66ccf877a0a","name":"Parse Decision, Agents & Steps","type":"n8n-nodes-base.code","position":[464,544],"parameters":{"jsCode":"const items = $input.all();\n\nreturn items.map(item => {\n\n const rawText = item.json.output || \"\";\n\n // Extract Decision\n const decisionMatch = rawText.match(/Decision:\\s*(.*)/);\n const decision = decisionMatch ? decisionMatch[1].trim() : null;\n\n // Extract Agents\n const agentRegex = /Agent Name:\\s*(.*?)\\n\\s*- Purpose:\\s*(.*?)\\n\\s*- Node:\\s*(.*?)\\n\\s*- Reason:\\s*(.*?)(?=\\n\\n|\\n\\d+\\. Agent Name:|$)/gs;\n\n let agents = [];\n let match;\n\n while ((match = agentRegex.exec(rawText)) !== null) {\n agents.push({\n name: match[1]?.trim() || \"\",\n purpose: match[2]?.trim() || \"\",\n node: match[3]?.trim() || \"\",\n reason: match[4]?.trim() || \"\",\n });\n }\n\n // Extract Workflow Steps\n const stepsRegex = /Step \\d+:\\s*(.*?)\\s*→/g;\n let steps = [];\n let stepMatch;\n\n while ((stepMatch = stepsRegex.exec(rawText)) !== null) {\n steps.push(stepMatch[1]?.trim() || \"\");\n }\n\n return {\n json: {\n decision,\n agents,\n workflow_flow: steps\n }\n };\n});"},"typeVersion":2},{"id":"7344bc04-e81b-47c1-8809-7563dad58a7b","name":"Build HTML Architecture Report","type":"n8n-nodes-base.code","position":[672,544],"parameters":{"jsCode":"const items = $input.all();\n\nreturn items.map(item => {\n\n const data = item.json;\n\n const decisionClass =\n data.decision === \"Multi-Agent Required\"\n ? \"multi\"\n : \"simple\";\n\n const agentsHTML = Array.isArray(data.agents)\n ? data.agents.map(agent => `\n