-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathSupportFlow Lite - Simple AI Customer Support Chatbot.json
More file actions
142 lines (142 loc) · 5.94 KB
/
SupportFlow Lite - Simple AI Customer Support Chatbot.json
File metadata and controls
142 lines (142 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
"name": "SupportFlow Lite — Simple AI Support Bot (No RAG)",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "supportflow-lite",
"responseMode": "responseNode",
"options": {}
},
"id": "trigger-webhook",
"name": "Receive Message",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [200, 400],
"webhookId": "supportflow-lite"
},
{
"parameters": {
"jsCode": "const body = $input.first().json.body || $input.first().json;\nconst message = body.message || body.text || '';\nconst sessionId = body.session_id || require('crypto').randomUUID();\nconst customerName = body.customer_name || 'Customer';\n\nif (!message || message.trim().length < 2) {\n throw new Error('Message is required.');\n}\n\nreturn [{ json: { message: message.trim(), sessionId, customerName, receivedAt: new Date().toISOString(), messageId: require('crypto').randomUUID() } }];"
},
"id": "validate-input",
"name": "Validate Input",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [420, 400]
},
{
"parameters": {
"model": "gpt-4o-mini",
"messages": {
"values": [
{
"role": "system",
"content": "=You are a helpful customer support assistant for {{ $env.SUPPORTFLOW_COMPANY_NAME || 'our company' }}.\n\nCompany info:\n{{ $env.SUPPORTFLOW_COMPANY_INFO || 'We are a technology company focused on providing excellent customer service.' }}\n\nRules:\n1. Be friendly, professional, and concise\n2. Answer based on the company info provided\n3. If you don't know the answer, say: 'I don't have that information. Let me connect you with our team at [support email].'\n4. Keep responses under 150 words\n5. Never make up product features, prices, or policies\n\nRespond in JSON: { \"answer\": \"...\", \"confidence\": 0.0-1.0, \"category\": \"faq|billing|technical|complaint|other\" }"
},
{
"role": "user",
"content": "=Customer {{$json.customerName}} asks:\n{{$json.message}}"
}
]
},
"options": { "temperature": 0.3, "maxTokens": 500, "responseFormat": "json_object" }
},
"id": "ai-respond",
"name": "AI: Generate Response",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1.8,
"position": [660, 400],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 2000
},
{
"parameters": {
"jsCode": "const original = $('Validate Input').first().json;\nconst aiRaw = $input.first().json;\nlet ai;\ntry {\n ai = JSON.parse(aiRaw.message?.content || aiRaw.content || '{}');\n} catch (e) {\n ai = { answer: 'Sorry, I had trouble processing that. Please try again.', confidence: 0, category: 'other' };\n}\n\nreturn [{ json: { ...original, answer: ai.answer || '', confidence: ai.confidence || 0, category: ai.category || 'other', respondedAt: new Date().toISOString() } }];"
},
"id": "merge-response",
"name": "Merge Response",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [900, 400]
},
{
"parameters": {
"operation": "append",
"documentId": { "__rl": true, "value": "={{ $env.SUPPORTFLOW_SHEET_ID }}", "mode": "id" },
"sheetName": { "__rl": true, "value": "Lite Conversations", "mode": "name" },
"columns": {
"mappingMode": "defineBelow",
"value": {
"Message ID": "={{ $json.messageId }}",
"Session ID": "={{ $json.sessionId }}",
"Customer": "={{ $json.customerName }}",
"Question": "={{ $json.message }}",
"Answer": "={{ $json.answer }}",
"Confidence": "={{ $json.confidence }}",
"Category": "={{ $json.category }}",
"Received": "={{ $json.receivedAt }}",
"Responded": "={{ $json.respondedAt }}"
}
},
"options": {}
},
"id": "log-sheets",
"name": "Log to Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [1140, 300],
"retryOnFail": true,
"maxTries": 2
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ success: true, messageId: $json.messageId, answer: $json.answer, confidence: $json.confidence, category: $json.category }) }}"
},
"id": "respond",
"name": "Respond to Customer",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [1140, 500]
},
{
"parameters": {
"content": "## SupportFlow Lite — Simple AI Bot\n\nNo vector database needed.\nUses company info from environment variable.\n\nBest for: Small businesses, MVPs, testing.\nSetup: 2 minutes (just OpenAI + Sheets).\n\nUpgrade to Main workflow when you\nneed RAG-powered knowledge base.",
"width": 350,
"height": 220,
"color": 6
},
"id": "note-overview",
"name": "Sticky Note: Lite",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [120, 140]
}
],
"connections": {
"Receive Message": {
"main": [[{ "node": "Validate Input", "type": "main", "index": 0 }]]
},
"Validate Input": {
"main": [[{ "node": "AI: Generate Response", "type": "main", "index": 0 }]]
},
"AI: Generate Response": {
"main": [[{ "node": "Merge Response", "type": "main", "index": 0 }]]
},
"Merge Response": {
"main": [[
{ "node": "Log to Sheets", "type": "main", "index": 0 },
{ "node": "Respond to Customer", "type": "main", "index": 0 }
]]
}
},
"settings": { "executionOrder": "v1", "saveManualExecutions": true },
"tags": [
{ "name": "SupportFlow", "id": "supportflow" },
{ "name": "AutoFlow", "id": "autoflow" },
{ "name": "Lite", "id": "lite" }
],
"meta": { "instanceId": "supportflow-lite-v1" }
}