Files

204 lines
5.1 KiB
JSON
Raw Permalink Normal View History

{
"name": "69 Writer (reference · Lab 01 example 2)",
"nodes": [
{
"name": "Writer webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
300
],
"parameters": {
"httpMethod": "POST",
"path": "my-writer",
"responseMode": "responseNode",
"options": {}
}
},
{
"name": "Has facts?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
200,
300
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c0",
"leftValue": "={{ $json.body.facts }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
}
},
{
"name": "Reject empty",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
420,
500
],
"parameters": {
"respondWith": "json",
"responseBody": "{ \"error\": \"facts are required\" }",
"options": {
"responseCode": 400
}
}
},
{
"name": "Writer agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
420,
300
],
"parameters": {
"promptType": "define",
"text": "=요청: {{ $('Writer webhook').first().json.body.request || 'IT 공지' }}\n사실:\n{{ $('Writer webhook').first().json.body.facts }}{{ $('Writer webhook').first().json.body.feedback ? '\\n\\n이전 초안:\\n' + $('Writer webhook').first().json.body.previous_draft + '\\n\\n검토 의견 (모두 고칠 것):\\n' + $('Writer webhook').first().json.body.feedback : '' }}",
"options": {
"systemMessage": "You are the writer of company IT notices, in Korean. Write one notice from the facts only. First line: a title in [square brackets]. Then 3 to 6 short lines. Copy every date and time exactly as written in the facts (for example 10월 23일, 22:00~24:00). Do not add promises, compensation, dates, people or contacts that are not in the facts. If reviewer feedback is given, rewrite the previous draft so that every point of the feedback is fixed, and change nothing else. Fixing never means adding: when you remove a phone number or e-mail address, do not put any other number, extension or address in its place. Return only the notice text.",
"maxIterations": 2
}
}
},
{
"name": "OpenAI chat model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
380,
520
],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4.1-mini"
},
"options": {
"temperature": 0
}
},
"credentials": {
"openAiApi": {
"id": "openAiCourse0001",
"name": "OpenAI (.env)"
}
}
},
{
"name": "Build draft",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
300
],
"parameters": {
"jsCode": "// The writer's contract: { draft }.\nconst draft = String($json.output ?? '').trim().replace(/^```\\w*\\s*|```$/g, '').trim();\nreturn [{ json: { draft } }];"
}
},
{
"name": "Send result",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
900,
300
],
"parameters": {
"respondWith": "json",
"responseBody": "={{ $json }}",
"options": {}
}
}
],
"connections": {
"Writer webhook": {
"main": [
[
{
"node": "Has facts?",
"type": "main",
"index": 0
}
]
]
},
"Has facts?": {
"main": [
[
{
"node": "Writer agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Reject empty",
"type": "main",
"index": 0
}
]
]
},
"OpenAI chat model": {
"ai_languageModel": [
[
{
"node": "Writer agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Writer agent": {
"main": [
[
{
"node": "Build draft",
"type": "main",
"index": 0
}
]
]
},
"Build draft": {
"main": [
[
{
"node": "Send result",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
}
}