436 lines
10 KiB
JSON
436 lines
10 KiB
JSON
{
|
|
"name": "74 IT helpdesk + prompt fallback (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": "956f6ead-f979-5d78-bedf-13743406c6b5"
|
|
},
|
|
{
|
|
"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": "b946f570-248c-5436-a6d6-06ab2b15db29"
|
|
},
|
|
{
|
|
"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": "e9818b28-ea3d-517c-ab00-02f86427c3c5"
|
|
},
|
|
{
|
|
"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": "0ffcc09f-8eff-56b4-801e-9c8e2a40930c"
|
|
},
|
|
{
|
|
"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": {
|
|
"timeout": 2000
|
|
}
|
|
},
|
|
"position": [
|
|
660,
|
|
300
|
|
],
|
|
"id": "578695ac-1a56-57c4-863b-08677838f02c",
|
|
"onError": "continueErrorOutput"
|
|
},
|
|
{
|
|
"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": [
|
|
1100,
|
|
300
|
|
],
|
|
"id": "322d506e-a6a2-52bc-b153-170da84009c2"
|
|
},
|
|
{
|
|
"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": [
|
|
1320,
|
|
300
|
|
],
|
|
"id": "3caf9b96-2920-54de-a905-3eabacb6f6e9"
|
|
},
|
|
{
|
|
"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": "={{ $('Registry prompt').isExecuted ? $('Registry prompt').first().json.text : $('Fallback prompt').first().json.text }}",
|
|
"maxIterations": 1
|
|
}
|
|
},
|
|
"position": [
|
|
1540,
|
|
300
|
|
],
|
|
"id": "500a6055-13cd-5000-9255-4f854efc5bb5"
|
|
},
|
|
{
|
|
"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": [
|
|
1540,
|
|
520
|
|
],
|
|
"id": "efcecd80-eb64-54b9-ba80-23ce47e0d416"
|
|
},
|
|
{
|
|
"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 prompt').isExecuted ? 'registry' : 'fallback') };\nreturn [{ json: result }];"
|
|
},
|
|
"position": [
|
|
1760,
|
|
300
|
|
],
|
|
"id": "999ca8b6-3571-5e6d-8c0d-d681a8cf40ee"
|
|
},
|
|
{
|
|
"name": "Send result",
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
|
"typeVersion": 1.1,
|
|
"parameters": {
|
|
"respondWith": "json",
|
|
"responseBody": "={{ $json }}",
|
|
"options": {}
|
|
},
|
|
"position": [
|
|
1980,
|
|
300
|
|
],
|
|
"id": "f9bbb5e8-0e9c-5c3b-9a23-204b66884821"
|
|
},
|
|
{
|
|
"name": "Registry prompt",
|
|
"type": "n8n-nodes-base.set",
|
|
"typeVersion": 3.4,
|
|
"position": [
|
|
880,
|
|
300
|
|
],
|
|
"id": "8161625d-2c7f-5acc-9377-3545a0ced05c",
|
|
"parameters": {
|
|
"assignments": {
|
|
"assignments": [
|
|
{
|
|
"id": "f0",
|
|
"name": "text",
|
|
"value": "={{ $json.text }}",
|
|
"type": "string"
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
}
|
|
},
|
|
{
|
|
"name": "Fallback prompt",
|
|
"type": "n8n-nodes-base.set",
|
|
"typeVersion": 3.4,
|
|
"position": [
|
|
880,
|
|
540
|
|
],
|
|
"id": "d9000207-de8d-561e-865c-216430daeaa5",
|
|
"parameters": {
|
|
"assignments": {
|
|
"assignments": [
|
|
{
|
|
"id": "f0",
|
|
"name": "text",
|
|
"value": "You are the company IT help desk. Answer in Korean in at most 3 sentences, using only the FAQ entries and the ticket record given. Never invent steps, dates or names. For a ticket, say its status and note. If the data does not answer the question, say \"찾지 못했습니다\" and that a staff member will help. Use 합니다체.",
|
|
"type": "string"
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
}
|
|
}
|
|
],
|
|
"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": "Registry prompt",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"node": "Fallback prompt",
|
|
"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
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Registry prompt": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Search FAQ",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Fallback prompt": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Search FAQ",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1"
|
|
}
|
|
}
|