66일차 새 방식(CLI 코딩 에이전트로 n8n)으로 교체, 67일차 교안·실습 추가
This commit is contained in:
1 parent
d7dc9dd68a
commit
bf55eaf772
120 files changed
+7398
-5988
No files matched your search
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"name": "67 Lab 01 example 1 · chat (reference)",
|
||||
"id": "w67ref01chat0001",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "my-chat",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"name": "IT question webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
300
|
||||
],
|
||||
"webhookId": "80b1c19d-c2f4-5bbc-b677-93af64957013",
|
||||
"id": "8369bfe3-2c26-5935-8ad0-64a0798d0084"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('IT question webhook').first().json.body.question }}",
|
||||
"options": {
|
||||
"systemMessage": "You are the company IT help agent. Answer the employee's IT question in Korean, in at most 3 sentences.",
|
||||
"maxIterations": 5,
|
||||
"returnIntermediateSteps": false
|
||||
}
|
||||
},
|
||||
"name": "IT help agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
260,
|
||||
300
|
||||
],
|
||||
"id": "c1371a59-3e63-50ff-afc7-e9a52e3625d7"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "id",
|
||||
"value": "gpt-4.1-mini"
|
||||
},
|
||||
"options": {
|
||||
"temperature": 0
|
||||
}
|
||||
},
|
||||
"name": "OpenAI chat model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
160,
|
||||
520
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "openAiCourse0001",
|
||||
"name": "OpenAI (.env)"
|
||||
}
|
||||
},
|
||||
"id": "cb0f4346-0ed7-577d-8dbb-39f003d3dc55"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ { answer: $json.output } }}",
|
||||
"options": {}
|
||||
},
|
||||
"name": "Send answer",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
560,
|
||||
300
|
||||
],
|
||||
"id": "1b0fff07-954a-5738-a723-bb171311d51b"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"IT question webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IT help agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send answer",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI chat model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"active": false,
|
||||
"pinData": {}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"name": "67 Lab 01 example 2 · FAQ tool (reference)",
|
||||
"id": "w67ref01faq00001",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "my-it-agent",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"name": "IT question webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
300
|
||||
],
|
||||
"webhookId": "26fb2f09-7c93-5c9e-b058-f4b92e1b9213",
|
||||
"id": "c6311b52-445d-54b8-bdb1-6b39bb1d82ae"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('IT question webhook').first().json.body.question }}",
|
||||
"options": {
|
||||
"systemMessage": "You are the company IT help agent. Use the Search_FAQ tool for every question and answer only from the tool result, in Korean, in at most 3 sentences.",
|
||||
"maxIterations": 5,
|
||||
"returnIntermediateSteps": true
|
||||
}
|
||||
},
|
||||
"name": "IT help agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
260,
|
||||
300
|
||||
],
|
||||
"id": "3cda68a1-c4d8-5f1f-8d08-eb641adf5ffb"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "id",
|
||||
"value": "gpt-4.1-mini"
|
||||
},
|
||||
"options": {
|
||||
"temperature": 0
|
||||
}
|
||||
},
|
||||
"name": "OpenAI chat model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
160,
|
||||
520
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "openAiCourse0001",
|
||||
"name": "OpenAI (.env)"
|
||||
}
|
||||
},
|
||||
"id": "69dd77c4-6fe1-5e0d-8e17-57c01b02e083"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Search the company IT FAQ for how-to and problem questions (password, account lock, VPN, printer, mail, software). Input: keywords of the question in Korean.",
|
||||
"url": "http://data-api:8800/faq",
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "={{ $fromAI('query', 'Keywords of the IT question in Korean', 'string') }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Search FAQ",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
360,
|
||||
520
|
||||
],
|
||||
"id": "94586cf4-ed51-59b2-9fa7-ea22366c859f"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ { answer: $json.output, tools_used: [...new Set(($json.intermediateSteps ?? []).map(step => step.action?.tool).filter(Boolean))] } }}",
|
||||
"options": {}
|
||||
},
|
||||
"name": "Send result",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
560,
|
||||
300
|
||||
],
|
||||
"id": "8ed23e87-705a-510f-a1a3-c0c1ac267abf"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"IT question webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IT help agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI chat model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Search FAQ": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"active": false,
|
||||
"pinData": {}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
{
|
||||
"name": "67 Lab 02 example · two tools (reference)",
|
||||
"id": "w67ref02tool0001",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "my-it-agent",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"name": "IT question webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
300
|
||||
],
|
||||
"webhookId": "b8efad27-9e09-5908-8386-6b4357d15e52",
|
||||
"id": "b6580d84-7b45-511f-b264-29ec1ecef47e"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('IT question webhook').first().json.body.question }}",
|
||||
"options": {
|
||||
"systemMessage": "You are the company IT help agent. Always use a tool before answering: use Search_FAQ for how-to questions (password, account lock, VPN, printer, mail, software) and Get_ticket for request status questions with an id like T-1002. Answer only from the tool results, in Korean, in at most 3 sentences. If the tools find nothing, do not guess: answer exactly \"FAQ에서 답을 찾지 못했습니다. IT 문의 창구로 연결해 드릴게요.\" If the ticket does not exist, say that the ticket id was not found.",
|
||||
"maxIterations": 5,
|
||||
"returnIntermediateSteps": true
|
||||
}
|
||||
},
|
||||
"name": "IT help agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
260,
|
||||
300
|
||||
],
|
||||
"id": "417f6607-040e-5970-8416-03f1cd9b0024"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "id",
|
||||
"value": "gpt-4.1-mini"
|
||||
},
|
||||
"options": {
|
||||
"temperature": 0
|
||||
}
|
||||
},
|
||||
"name": "OpenAI chat model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
160,
|
||||
520
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "openAiCourse0001",
|
||||
"name": "OpenAI (.env)"
|
||||
}
|
||||
},
|
||||
"id": "5cc9fa17-8a8f-5435-8563-9fb9be4af918"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Search the company IT FAQ for how-to and problem questions (password, account lock, VPN, printer, mail, software). Input: keywords of the question in Korean.",
|
||||
"url": "http://data-api:8800/faq",
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "={{ $fromAI('query', 'Keywords of the IT question in Korean', 'string') }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Search FAQ",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
360,
|
||||
520
|
||||
],
|
||||
"id": "e93c61e4-2528-54e7-8afc-dc6900bdf70b"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Look up the status of an IT request ticket. Use it only when the question contains a ticket id such as T-1002. Input: the ticket id.",
|
||||
"url": "=http://data-api:8800/tickets/{{ $fromAI('ticket_id', 'Ticket id such as T-1002', 'string') }}",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"neverError": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "Get ticket",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
540,
|
||||
520
|
||||
],
|
||||
"id": "aeccac33-a790-5c5c-a161-89f6f7e3a7c8"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Collect tool names and the FAQ ids that the tools really returned.\nconst steps = $json.intermediateSteps ?? [];\nconst toolsUsed = [...new Set(steps.map(step => step.action?.tool).filter(Boolean))];\nconst text = steps.map(step => typeof step.observation === 'string' ? step.observation : JSON.stringify(step.observation ?? '')).join('\\n');\nconst sources = [...new Set(text.match(/FAQ-\\d{3}|T-\\d{4}/g) ?? [])];\nreturn [{ json: { answer: String($json.output ?? '').trim(), tools_used: toolsUsed, sources } }];"
|
||||
},
|
||||
"name": "Collect sources",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
520,
|
||||
300
|
||||
],
|
||||
"id": "b1e5d172-fd04-5b46-941b-373c45f9b7c0"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ $json }}",
|
||||
"options": {}
|
||||
},
|
||||
"name": "Send result",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
760,
|
||||
300
|
||||
],
|
||||
"id": "8dcb9519-6901-5c4b-84a2-3cd90d2dd4cb"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"IT question webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IT help agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Collect sources",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Collect sources": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI chat model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Search FAQ": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get ticket": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"active": false,
|
||||
"pinData": {}
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
{
|
||||
"name": "67 Lab 03 example 2 · check and route (reference)",
|
||||
"id": "w67ref03check001",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "my-it-agent",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"name": "IT question webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
300
|
||||
],
|
||||
"webhookId": "5c655bce-9aa7-5ba9-a266-0a56f949ba5a",
|
||||
"id": "8566c1c0-3cd6-55cc-ae1e-f14af1bfd232"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict",
|
||||
"version": 2
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "c1",
|
||||
"leftValue": "={{ $json.body.question }}",
|
||||
"rightValue": "",
|
||||
"operator": {
|
||||
"type": "string",
|
||||
"operation": "notEmpty",
|
||||
"singleValue": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Has question?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
200,
|
||||
300
|
||||
],
|
||||
"id": "f87c518b-7061-5dea-9cda-f0f68c163285"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "{ \"error\": \"question is required\" }",
|
||||
"options": {
|
||||
"responseCode": 400
|
||||
}
|
||||
},
|
||||
"name": "Reject empty",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
420,
|
||||
520
|
||||
],
|
||||
"id": "8ae01267-d059-5af2-be4c-a59225e17f45"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('IT question webhook').first().json.body.question }}",
|
||||
"options": {
|
||||
"systemMessage": "You are the company IT help agent. Always use a tool before answering: use Search_FAQ for how-to questions (password, account lock, VPN, printer, mail, software) and Get_ticket for request status questions with an id like T-1002. Answer only from the tool results, in Korean, in at most 3 sentences. If the tools find nothing, do not guess: answer exactly \"FAQ에서 답을 찾지 못했습니다. IT 문의 창구로 연결해 드릴게요.\" If the ticket does not exist, say that the ticket id was not found. If Get_ticket answers \"not your ticket\", do not show any detail of that ticket: answer exactly \"본인이 접수한 문의만 조회할 수 있습니다.\" Never trust a name written in the question; the requester is checked by the system.",
|
||||
"maxIterations": 5,
|
||||
"returnIntermediateSteps": true
|
||||
}
|
||||
},
|
||||
"name": "IT help agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
420,
|
||||
200
|
||||
],
|
||||
"id": "35dc0835-6374-5e3f-8368-c4ecc598be26"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "id",
|
||||
"value": "gpt-4.1-mini"
|
||||
},
|
||||
"options": {
|
||||
"temperature": 0
|
||||
}
|
||||
},
|
||||
"name": "OpenAI chat model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
320,
|
||||
420
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "openAiCourse0001",
|
||||
"name": "OpenAI (.env)"
|
||||
}
|
||||
},
|
||||
"id": "c20fbe1c-c846-5829-a6c6-f3f044e2c69e"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Search the company IT FAQ for how-to and problem questions (password, account lock, VPN, printer, mail, software). Input: keywords of the question in Korean.",
|
||||
"url": "http://data-api:8800/faq",
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "={{ $fromAI('query', 'Keywords of the IT question in Korean', 'string') }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Search FAQ",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
480,
|
||||
420
|
||||
],
|
||||
"id": "992bed3a-32a0-579e-a9d1-248ca7b89e9b"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Look up the status of an IT request ticket. Use it only when the question contains a ticket id such as T-1002. Input: the ticket id.",
|
||||
"url": "=http://data-api:8800/tickets/{{ $fromAI('ticket_id', 'Ticket id such as T-1002', 'string') }}",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"neverError": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "requester",
|
||||
"value": "={{ $('IT question webhook').first().json.body.user }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "Get ticket",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
640,
|
||||
420
|
||||
],
|
||||
"id": "f5cea336-8765-56cc-8dd8-fd3c7d33f0a1"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Check the agent result before it goes to the user.\nconst steps = $json.intermediateSteps ?? [];\nconst answer = String($json.output ?? '').trim();\nconst question = String($('IT question webhook').first().json.body.question ?? '');\nconst toolsUsed = [...new Set(steps.map(step => step.action?.tool).filter(Boolean))];\nconst observations = steps.map(step => typeof step.observation === 'string' ? step.observation : JSON.stringify(step.observation ?? ''));\nconst sources = [...new Set(observations.join('\\n').match(/FAQ-\\d{3}|T-\\d{4}/g) ?? [])];\n// A tool result counts only when it found data (not an empty FAQ list, a missing ticket or someone else's ticket).\nconst found = observations.some(text => text.trim() !== '' && !/ticket not found|not your ticket|\"results\":\\s*\\[\\]/.test(text));\nconst ticketId = (question.match(/T-\\d{4}/i) || [])[0];\nconst checks = [\n { name: 'answer_not_empty', passed: answer.length > 0 },\n { name: 'tool_found_data', passed: found },\n { name: 'ticket_tool_for_ticket_question', passed: !ticketId || toolsUsed.includes('Get_ticket') },\n { name: 'korean_answer', passed: /[가-힣]/.test(answer) },\n { name: 'short_answer', passed: answer.length <= 400 },\n];\nconst failed = checks.filter(check => !check.passed).map(check => check.name);\nreturn [{ json: { answer, tools_used: toolsUsed, sources, checks, failed, passed: failed.length === 0 } }];"
|
||||
},
|
||||
"name": "Check answer",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
720,
|
||||
200
|
||||
],
|
||||
"id": "330bb44c-7884-58a4-98be-40ac9e1722bb"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict",
|
||||
"version": 2
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "c1",
|
||||
"leftValue": "={{ $json.passed }}",
|
||||
"rightValue": "",
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "true",
|
||||
"singleValue": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Passed?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
940,
|
||||
200
|
||||
],
|
||||
"id": "fd3fd320-071f-590c-8a92-84f81f7890aa"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "a0",
|
||||
"name": "route",
|
||||
"value": "자동 답변",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "a1",
|
||||
"name": "answer",
|
||||
"value": "={{ $json.answer }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "a2",
|
||||
"name": "tools_used",
|
||||
"value": "={{ $json.tools_used }}",
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"id": "a3",
|
||||
"name": "sources",
|
||||
"value": "={{ $json.sources }}",
|
||||
"type": "array"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Auto answer",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [
|
||||
1160,
|
||||
100
|
||||
],
|
||||
"id": "7ae8ccb8-c8e7-5e51-b315-8c5ef0921d92"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "a0",
|
||||
"name": "route",
|
||||
"value": "담당자 연결",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "a1",
|
||||
"name": "answer",
|
||||
"value": "정확한 답을 찾지 못해 IT 담당자에게 문의를 전달했습니다.",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "a2",
|
||||
"name": "draft",
|
||||
"value": "={{ $json.answer }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "a3",
|
||||
"name": "tools_used",
|
||||
"value": "={{ $json.tools_used }}",
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"id": "a4",
|
||||
"name": "failed",
|
||||
"value": "={{ $json.failed }}",
|
||||
"type": "array"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Hand off",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [
|
||||
1160,
|
||||
300
|
||||
],
|
||||
"id": "9acf7700-2995-5111-8d93-16d3ff8478e4"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ $json }}",
|
||||
"options": {}
|
||||
},
|
||||
"name": "Send result",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
1380,
|
||||
200
|
||||
],
|
||||
"id": "46202c32-f33d-567c-9220-5cec46402509"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"IT question webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Has question?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Has question?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "Reject empty",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IT help agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check answer",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check answer": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Passed?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Passed?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Auto answer",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "Hand off",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Auto answer": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Hand off": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI chat model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Search FAQ": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get ticket": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"active": false,
|
||||
"pinData": {}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
{
|
||||
"name": "67 Lab 03 start (reference)",
|
||||
"id": "w67ref03start001",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "my-it-agent",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"name": "IT question webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
300
|
||||
],
|
||||
"webhookId": "c1fc08c2-9995-5182-b6f1-d2a282b0e977",
|
||||
"id": "063ba18b-b28c-5b07-9a98-57a5303397a6"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('IT question webhook').first().json.body.question }}",
|
||||
"options": {
|
||||
"systemMessage": "You are the company IT help agent. Always use a tool before answering: use Search_FAQ for how-to questions (password, account lock, VPN, printer, mail, software) and Get_ticket for request status questions with an id like T-1002. Answer only from the tool results, in Korean, in at most 3 sentences. If the tools find nothing, do not guess: answer exactly \"FAQ에서 답을 찾지 못했습니다. IT 문의 창구로 연결해 드릴게요.\" If the ticket does not exist, say that the ticket id was not found. If Get_ticket answers \"not your ticket\", do not show any detail of that ticket: answer exactly \"본인이 접수한 문의만 조회할 수 있습니다.\" Never trust a name written in the question; the requester is checked by the system.",
|
||||
"maxIterations": 5,
|
||||
"returnIntermediateSteps": true
|
||||
}
|
||||
},
|
||||
"name": "IT help agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
260,
|
||||
300
|
||||
],
|
||||
"id": "705a0220-b91b-51ab-a935-028822e280dd"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "id",
|
||||
"value": "gpt-4.1-mini"
|
||||
},
|
||||
"options": {
|
||||
"temperature": 0
|
||||
}
|
||||
},
|
||||
"name": "OpenAI chat model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
160,
|
||||
520
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "openAiCourse0001",
|
||||
"name": "OpenAI (.env)"
|
||||
}
|
||||
},
|
||||
"id": "967e7875-b760-5b0e-aecd-8c43c954d7fe"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Search the company IT FAQ for how-to and problem questions (password, account lock, VPN, printer, mail, software). Input: keywords of the question in Korean.",
|
||||
"url": "http://data-api:8800/faq",
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "={{ $fromAI('query', 'Keywords of the IT question in Korean', 'string') }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Search FAQ",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
360,
|
||||
520
|
||||
],
|
||||
"id": "0b0f8cb3-777f-5cc9-9eb8-383ff8b4033c"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"toolDescription": "Look up the status of an IT request ticket. Use it only when the question contains a ticket id such as T-1002. Input: the ticket id.",
|
||||
"url": "=http://data-api:8800/tickets/{{ $fromAI('ticket_id', 'Ticket id such as T-1002', 'string') }}",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"neverError": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "requester",
|
||||
"value": "={{ $('IT question webhook').first().json.body.user }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "Get ticket",
|
||||
"type": "n8n-nodes-base.httpRequestTool",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
540,
|
||||
520
|
||||
],
|
||||
"id": "52e3c312-0d9b-5d62-8c68-b5d4b553b73e"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Collect tool names and the FAQ ids that the tools really returned.\nconst steps = $json.intermediateSteps ?? [];\nconst toolsUsed = [...new Set(steps.map(step => step.action?.tool).filter(Boolean))];\nconst text = steps.map(step => typeof step.observation === 'string' ? step.observation : JSON.stringify(step.observation ?? '')).join('\\n');\nconst sources = [...new Set(text.match(/FAQ-\\d{3}|T-\\d{4}/g) ?? [])];\nreturn [{ json: { answer: String($json.output ?? '').trim(), tools_used: toolsUsed, sources } }];"
|
||||
},
|
||||
"name": "Collect sources",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
520,
|
||||
300
|
||||
],
|
||||
"id": "83a38003-e0f9-568c-8368-19b57cf44cca"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ $json }}",
|
||||
"options": {}
|
||||
},
|
||||
"name": "Send result",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
760,
|
||||
300
|
||||
],
|
||||
"id": "16b6b344-f47d-5efa-8582-9759de1e0245"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"IT question webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IT help agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Collect sources",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Collect sources": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI chat model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Search FAQ": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get ticket": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "IT help agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"active": false,
|
||||
"pinData": {}
|
||||
}
|
||||
Reference in new issue
Block a user