{
 "name": "[노드 한 장] Call n8n Workflow Tool · 호출하는 AI",
 "nodes": [
  {
   "id": "manual",
   "name": "Run manually",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ],
   "parameters": {}
  },
  {
   "id": "sample",
   "name": "Self-written sample order",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    240,
    0
   ],
   "parameters": {
    "jsCode": "return [{json:{sample:true,question:'샘플 상품 단가 50000원, 할인율 10퍼센트, 수량 3개입니다. 계산 도구를 호출해서 할인 후 총액을 알려 주세요.'}}];"
   }
  },
  {
   "id": "agent",
   "name": "AI Agent calls calculation tool",
   "type": "@n8n/n8n-nodes-langchain.agent",
   "typeVersion": 3.1,
   "position": [
    480,
    0
   ],
   "parameters": {
    "promptType": "define",
    "text": "={{ $json.question }}",
    "options": {
     "systemMessage": "당신은 샘플 주문 계산을 요청하는 실습 도우미입니다. 반드시 CalculateDiscountTool을 실제 한 번 호출해 입력 숫자를 전달하고, 도구가 반환한 total을 그대로 사용해 한국어로 답하세요. 직접 암산하거나 도구 결과 없이 수치를 추측하지 마세요. 도구 결과가 없거나 오류면 계산을 완료하지 못했다고 말하세요. 최종 답에는 샘플이며 서브 워크플로우 계산 결과라고 명시하세요.",
     "maxIterations": 3,
     "returnIntermediateSteps": true
    }
   }
  },
  {
   "id": "model",
   "name": "OpenAI Chat Model",
   "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
   "typeVersion": 1.3,
   "position": [
    420,
    250
   ],
   "parameters": {
    "model": {
     "__rl": true,
     "mode": "id",
     "value": "gpt-4.1-mini"
    },
    "responsesApiEnabled": false,
    "options": {
     "temperature": 0,
     "maxTokens": 250
    }
   }
  },
  {
   "id": "tool",
   "name": "Call n8n Workflow Tool",
   "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
   "typeVersion": 2.1,
   "position": [
    680,
    250
   ],
   "parameters": {
    "name": "CalculateDiscountTool",
    "description": "Call the owned sample sub-workflow to calculate the discounted order total. Pass the user-provided unitPrice, discountPercent and quantity as numbers. The child Code performs the arithmetic.",
    "source": "database",
    "workflowId": {
     "__rl": true,
     "mode": "id",
     "value": "YOUR_SUB_WORKFLOW_ID"
    },
    "workflowInputs": {
     "mappingMode": "defineBelow",
     "value": {
      "unitPrice": "={{ $fromAI('unitPrice', '상품 단가 숫자', 'number') }}",
      "discountPercent": "={{ $fromAI('discountPercent', '할인율 퍼센트 숫자', 'number') }}",
      "quantity": "={{ $fromAI('quantity', '상품 수량 정수', 'number') }}"
     },
     "matchingColumns": [],
     "schema": [
      {
       "id": "unitPrice",
       "displayName": "unitPrice",
       "required": true,
       "defaultMatch": false,
       "display": true,
       "type": "number",
       "canBeUsedToMatch": true
      },
      {
       "id": "discountPercent",
       "displayName": "discountPercent",
       "required": true,
       "defaultMatch": false,
       "display": true,
       "type": "number",
       "canBeUsedToMatch": true
      },
      {
       "id": "quantity",
       "displayName": "quantity",
       "required": true,
       "defaultMatch": false,
       "display": true,
       "type": "number",
       "canBeUsedToMatch": true
      }
     ],
     "attemptToConvertTypes": false,
     "convertFieldsToString": false
    }
   }
  }
 ],
 "connections": {
  "Run manually": {
   "main": [
    [
     {
      "node": "Self-written sample order",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Self-written sample order": {
   "main": [
    [
     {
      "node": "AI Agent calls calculation tool",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "OpenAI Chat Model": {
   "ai_languageModel": [
    [
     {
      "node": "AI Agent calls calculation tool",
      "type": "ai_languageModel",
      "index": 0
     }
    ]
   ]
  },
  "Call n8n Workflow Tool": {
   "ai_tool": [
    [
     {
      "node": "AI Agent calls calculation tool",
      "type": "ai_tool",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}