357 lines
8.2 KiB
JSON
357 lines
8.2 KiB
JSON
{
|
|||
|
|
"name": "74 IT helpdesk + prompt registry (answer)",
|
||
|
|
"nodes": [
|
||
|
|
{
|
||
|
|
"name": "Question webhook",
|
||
|
|
"type": "n8n-nodes-base.webhook",
|
||
|
|
"typeVersion": 2,
|
||
|
|
"parameters": {
|
||
|
|
"httpMethod": "POST",
|
||
|
|
"path": "my-helpdesk",
|
||
|
|
"responseMode": "responseNode",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"webhookId": "de518e93-ed19-541f-a6fc-687a4efaf1b2",
|
||
|
|
"position": [
|
||
|
|
0,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "d898f230-a253-55da-9ec5-4288291c08dd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Has question?",
|
||
|
|
"type": "n8n-nodes-base.if",
|
||
|
|
"typeVersion": 2.2,
|
||
|
|
"parameters": {
|
||
|
|
"conditions": {
|
||
|
|
"options": {
|
||
|
|
"caseSensitive": true,
|
||
|
|
"leftValue": "",
|
||
|
|
"typeValidation": "loose",
|
||
|
|
"version": 2
|
||
|
|
},
|
||
|
|
"conditions": [
|
||
|
|
{
|
||
|
|
"id": "c1",
|
||
|
|
"leftValue": "={{ $json.body.question }}",
|
||
|
|
"rightValue": "",
|
||
|
|
"operator": {
|
||
|
|
"type": "string",
|
||
|
|
"operation": "notEmpty",
|
||
|
|
"singleValue": true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"combinator": "and"
|
||
|
|
},
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
220,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "185f04ea-0ee8-514b-b3fd-11b89b1c0c2e"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Reject empty",
|
||
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
||
|
|
"typeVersion": 1.1,
|
||
|
|
"parameters": {
|
||
|
|
"respondWith": "json",
|
||
|
|
"responseBody": "{ \"error\": \"question is required\" }",
|
||
|
|
"options": {
|
||
|
|
"responseCode": 400
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
440,
|
||
|
|
560
|
||
|
|
],
|
||
|
|
"id": "8a3b377f-f3fa-56e8-a9c4-98a3e014ce61"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Release info",
|
||
|
|
"type": "n8n-nodes-base.set",
|
||
|
|
"typeVersion": 3.4,
|
||
|
|
"parameters": {
|
||
|
|
"assignments": {
|
||
|
|
"assignments": [
|
||
|
|
{
|
||
|
|
"id": "r1",
|
||
|
|
"name": "release",
|
||
|
|
"value": "1.0.0",
|
||
|
|
"type": "string"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"id": "r2",
|
||
|
|
"name": "prompt_version",
|
||
|
|
"value": "p1",
|
||
|
|
"type": "string"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"id": "r3",
|
||
|
|
"name": "model",
|
||
|
|
"value": "gpt-4.1-mini",
|
||
|
|
"type": "string"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
440,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "b33700b3-849d-5b4f-8d8c-42723207125b"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Get prompt",
|
||
|
|
"type": "n8n-nodes-base.httpRequest",
|
||
|
|
"typeVersion": 4.2,
|
||
|
|
"parameters": {
|
||
|
|
"url": "=http://data-api:8800/prompts/helpdesk/{{ $('Release info').first().json.prompt_version }}",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
660,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "a39d24f1-c645-50c9-940e-59e381744fc1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Search FAQ",
|
||
|
|
"type": "n8n-nodes-base.httpRequest",
|
||
|
|
"typeVersion": 4.2,
|
||
|
|
"parameters": {
|
||
|
|
"url": "http://data-api:8800/faq",
|
||
|
|
"options": {},
|
||
|
|
"sendQuery": true,
|
||
|
|
"queryParameters": {
|
||
|
|
"parameters": [
|
||
|
|
{
|
||
|
|
"name": "q",
|
||
|
|
"value": "={{ $('Question webhook').first().json.body.question }}"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
880,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "c7fa8ee8-ba2b-5266-9d1a-ffa5dd8743b5"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Get ticket",
|
||
|
|
"type": "n8n-nodes-base.httpRequest",
|
||
|
|
"typeVersion": 4.2,
|
||
|
|
"parameters": {
|
||
|
|
"url": "=http://data-api:8800/tickets/{{ (($('Question webhook').first().json.body.question.match(/T-?\\d{4}/i) || ['NONE'])[0]).toUpperCase().replace(/^T(\\d)/, 'T-$1') }}",
|
||
|
|
"options": {
|
||
|
|
"response": {
|
||
|
|
"response": {
|
||
|
|
"neverError": true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"sendQuery": true,
|
||
|
|
"queryParameters": {
|
||
|
|
"parameters": [
|
||
|
|
{
|
||
|
|
"name": "requester",
|
||
|
|
"value": "={{ $('Question webhook').first().json.body.user ?? '' }}"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
1100,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "b4fd19f5-03d4-5b31-a654-4b0ac4c32fac"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Answer",
|
||
|
|
"type": "@n8n/n8n-nodes-langchain.agent",
|
||
|
|
"typeVersion": 3.1,
|
||
|
|
"parameters": {
|
||
|
|
"promptType": "define",
|
||
|
|
"text": "=질문: {{ $('Question webhook').first().json.body.question }}\nFAQ: {{ JSON.stringify($('Search FAQ').first().json.results ?? []) }}\n접수 건: {{ JSON.stringify($('Get ticket').first().json) }}",
|
||
|
|
"options": {
|
||
|
|
"systemMessage": "={{ $('Get prompt').first().json.text }}",
|
||
|
|
"maxIterations": 1
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
1320,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "1a80728e-83e0-58d7-9477-42d4099502c6"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Answer model",
|
||
|
|
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||
|
|
"typeVersion": 1.2,
|
||
|
|
"parameters": {
|
||
|
|
"model": {
|
||
|
|
"__rl": true,
|
||
|
|
"mode": "id",
|
||
|
|
"value": "={{ $('Release info').first().json.model }}"
|
||
|
|
},
|
||
|
|
"options": {
|
||
|
|
"temperature": 0
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"credentials": {
|
||
|
|
"openAiApi": {
|
||
|
|
"id": "openAiCourse0001",
|
||
|
|
"name": "OpenAI (.env)"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
1320,
|
||
|
|
520
|
||
|
|
],
|
||
|
|
"id": "4c69869f-3300-5834-8124-e64dfcc8135e"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Build result",
|
||
|
|
"type": "n8n-nodes-base.code",
|
||
|
|
"typeVersion": 2,
|
||
|
|
"parameters": {
|
||
|
|
"jsCode": "const results = $('Search FAQ').first().json.results ?? [];\nconst result = { route: '자동 답변', answer: String($json.output ?? '').trim(), sources: results.map((r) => r.id) };\nconst i = $('Release info').first().json;\nresult.version = { release: i.release, prompt_version: i.prompt_version, model: i.model, prompt_source: 'registry' };\nreturn [{ json: result }];"
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
1540,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "7c284309-570a-5987-b139-e1be350994fd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Send result",
|
||
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
||
|
|
"typeVersion": 1.1,
|
||
|
|
"parameters": {
|
||
|
|
"respondWith": "json",
|
||
|
|
"responseBody": "={{ $json }}",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"position": [
|
||
|
|
1760,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"id": "32a9aaf4-2a59-5388-8a24-0e9f28c346e4"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"connections": {
|
||
|
|
"Question webhook": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Has question?",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Has question?": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Release info",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
],
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Reject empty",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Release info": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Get prompt",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Get prompt": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Search FAQ",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Search FAQ": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Get ticket",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Get ticket": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Answer",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Answer model": {
|
||
|
|
"ai_languageModel": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Answer",
|
||
|
|
"type": "ai_languageModel",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Answer": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Build result",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Build result": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Send result",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"settings": {
|
||
|
|
"executionOrder": "v1"
|
||
|
|
}
|
||
|
|
}
|