工作流文件
n8n-网店AI客服-国内版.json
{"name":"网店 AI 客服(国内版)","nodes":[{"parameters":{"content":"## 网店 AI 客服(国内版)\n派派编辑部改自 n8n 官方模板 #13353 + #13354(问答客服两件套)和 #2465(商品手册销售员)。\n\n**第一次用:**\n1. 双击「模型」,Credential 里新建 OpenAI 类型的凭据:API Key 填 DeepSeek 的 Key,Base URL 改成 `https://api.deepseek.com`。「模型(录问答用)」选同一个凭据\n2. 鼠标移到下方「第一次用:建表」节点上,点「Execute workflow」,自动建好 商品手册、常见问题、待人工 三张表,填进示例茶叶店的数据\n3. 左侧 Overview → Data tables,把示例数据换成你自己的商品和问答\n4. 双击「预检和设置」,改开头的店名、每日上限,要企业微信提醒就填群机器人地址\n5. 点右上角 Publish,双击「顾客聊天入口」复制 Chat URL\n\n**它守的规矩:** 只按两张表回答;查不到、要退款、要团购报价、要找真人就转人工,记进「待人工」表;砍价直接回绝;每条回复前面加【AI 回复】;回复里出现打折、退款承诺会被程序拦下。","height":640,"width":540,"color":4},"id":"e7b9acf0-4807-5a13-8989-5369c2075c63","name":"说明","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-1180,-420]},{"parameters":{"content":"### 顾客聊天\n顾客发一句 → 预检(限长度、限次数)→ AI 客服查表回答 → 检查回复(加【AI 回复】、拦承诺、标金额)→ 有转人工就记一笔、发企业微信 → 回复顾客","height":760,"width":1880,"color":7},"id":"7d0446b1-d04f-545d-96f8-e9ec3dd30cdb","name":"聊天便签","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-600,-420]},{"parameters":{"content":"### 第一次用:建表\n鼠标移到触发节点上,点「Execute workflow」运行一次。表已经有了就不会重建,示例数据按商品名、问题去重,多点几次也不会重复。","height":300,"width":1880,"color":7},"id":"e162dba6-74c4-57f9-80a9-67b03188cab0","name":"建表便签","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-600,420]},{"parameters":{"content":"### 店员录问答(官方模板 #13353 的做法)\n店员打开这个表单录「顾客常问的问题 + 标准答案」,AI 补几种顾客可能的问法,存进常见问题表。表单要登录 n8n 才能打开。","height":440,"width":1180,"color":7},"id":"fade24ab-f347-5731-bc7f-a94446f73cc5","name":"录问答便签","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-600,760]},{"parameters":{"public":true,"mode":"hostedChat","authentication":"none","initialMessages":"你好,我是松间茶舍的 AI 客服助手,可以回答商品、发货、售后规则方面的问题。\n我的回答由 AI 生成,价格和售后以店员确认为准;复杂问题我会转给店员。请不要发送身份证号、银行卡号这类信息。","options":{"title":"松间茶舍 · AI 客服","subtitle":"AI 回复仅供参考,复杂问题会转给店员","inputPlaceholder":"问问商品、发货、售后……","responseMode":"lastNode"}},"id":"0ad69246-2760-5cb3-81a7-b44d67128b4e","name":"顾客聊天入口","type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.4,"position":[-520,-120]},{"parameters":{"jsCode":"// 预检和设置:店名、上限、企业微信地址都在这里改\nconst SHOP_NAME = '松间茶舍';\nconst MAX_LEN = 300; // 一条消息最多多少字,太长的不交给 AI\nconst SESSION_LIMIT = 30; // 同一个聊天窗口一天最多问几次\nconst DAILY_LIMIT = 300; // 全店一天最多回答几次(防止被人刷额度)\nconst WECOM_WEBHOOK = ''; // 企业微信群机器人地址,留空就不发提醒\n\nconst item = $input.first().json;\nconst text = String(item.chatInput ?? '').trim();\nconst sessionId = String(item.sessionId ?? 'unknown');\nconst day = $now.toFormat('yyyy-MM-dd');\nconst st = $getWorkflowStaticData('global'); // 只有发布后的正式运行才会保存\nif (st.day !== day) { st.day = day; st.total = 0; st.sessions = {}; }\nst.sessions[sessionId] = (st.sessions[sessionId] || 0) + 1;\nst.total += 1;\n\nlet blocked = '';\nif (!text) blocked = '请输入你想问的问题。';\nelse if (st.total > DAILY_LIMIT) blocked = '今天咨询的人太多,AI 客服暂停了,明天恢复;急事请打店铺页面上的电话找店员。';\nelse if (st.sessions[sessionId] > SESSION_LIMIT) blocked = '今天这个窗口问得比较多了,AI 客服先停一下,明天再来;急事请打店铺页面上的电话找店员。';\nelse if (text.length > MAX_LEN) blocked = `一次最多 ${MAX_LEN} 个字,请分几次说,或者说得简短一点。`;\n\nreturn [{ json: { chatInput: text.slice(0, MAX_LEN), sessionId, blocked, shopName: SHOP_NAME, wecomWebhook: WECOM_WEBHOOK,\n reply: blocked ? `【AI 回复】\\n${blocked}` : '' } }];"},"id":"135c70bf-fef1-5c05-a586-46d4745c2e00","name":"预检和设置","type":"n8n-nodes-base.code","typeVersion":2,"position":[-300,-120]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"loose","version":2},"conditions":[{"id":"c1","leftValue":"={{ $json.blocked }}","rightValue":"","operator":{"type":"string","operation":"empty","singleValue":true}}],"combinator":"and"},"options":{}},"id":"7941740a-0d0a-5ebe-84b3-ae579a515a73","name":"放行吗","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[-80,-120]},{"parameters":{"assignments":{"assignments":[{"id":"o1","name":"output","value":"={{ $json.reply }}","type":"string"}]},"options":{}},"id":"55fe6ac5-797d-57bf-adce-aa138d801bf1","name":"拦下时的回复","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[-100,160]},{"parameters":{"options":{"systemMessage":"=你是「{{ $json.shopName }}」的 AI 客服助手,用简体中文回答顾客。你不是真人,顾客问起就如实说自己是 AI 助手。\n\n你有三个工具:\n- Query_Products:读本店的商品手册(商品名、类别、产地、规格、价格、口感、冲泡方法、保存方法、库存、备注)。顾客问商品、推荐、价格、库存、怎么泡、怎么存时调用。\n- Query_FAQ:读本店的常见问题(发货、运费、退换货、发票、优惠、礼盒、门店、人工客服、团购等)。顾客问店铺规则和服务时调用。\n- Handoff_To_Human:把问题转给店员。以下情况必须调用:①商品手册和常见问题里都查不到答案;②顾客要退款、退换货、投诉,或者说商品有质量问题;③顾客要团购、批发报价;④顾客要找真人。顾客只是砍价、要折扣,按第 2 条回绝就行,不用转人工。顾客之后补了手机号或微信号,再调用一次,把联系方式带上。\n\n回答规矩:\n1. 只根据工具查到的内容回答。查不到就直说「这个我这里查不到」,然后转人工;不要猜,不要用常识补,不要编产地、检测报告、功效、到货日期。\n2. 价格只说商品手册里的标价。不打折、不议价、不送赠品、不承诺任何优惠;顾客砍价,就说明本店价格统一,活动以店铺首页公告为准。\n3. 不承诺退款、退货、换货、赔偿、补发。常见问题里写了的退换规则可以照着说,但要讲明由店员核实后处理,并且转人工。\n4. 不回答和本店商品、服务无关的问题。问到身体健康、疾病、孕期能不能喝,说明你不能给健康建议,请咨询医生。\n5. 转人工后告诉顾客:已经转给店员,店员会在营业时间(每天 9:30–21:00)联系。顾客愿意留手机号或微信号就记下;不要主动要身份证号、银行卡号、详细住址、支付密码,顾客发了也不要复述。\n6. 回答简短,先给结论,150 字以内。不要说「已为您下单」「已为您退款」这类你做不到的事。","maxIterations":6,"returnIntermediateSteps":true}},"id":"20fd1a3f-b738-5163-b2f0-f779912d294f","name":"AI 客服","type":"@n8n/n8n-nodes-langchain.agent","typeVersion":3.1,"position":[180,-160],"onError":"continueErrorOutput"},{"parameters":{"model":{"__rl":true,"mode":"id","value":"deepseek-flash"},"responsesApiEnabled":false,"options":{"extraBody":"{\n \"thinking\": { \"type\": \"disabled\" }\n}"}},"id":"89f4f42d-81be-50b1-a0a3-ddce2cba9d45","name":"模型","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.3,"position":[60,160]},{"parameters":{"contextWindowLength":10},"id":"f86fa034-756c-59dc-8f49-3654c3b6029a","name":"对话记忆","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","typeVersion":1.3,"position":[220,160]},{"parameters":{"descriptionType":"manual","toolDescription":"读本店商品手册的全部商品:商品名、类别、产地、规格、价格(元)、口感、冲泡方法、保存方法、库存、备注。","operation":"get","returnAll":true,"dataTableId":{"__rl":true,"mode":"name","value":"商品手册"}},"id":"82dbf64e-62b7-515f-b917-54a7e8e6b4ae","name":"Query_Products","type":"n8n-nodes-base.dataTableTool","typeVersion":1.1,"position":[380,160]},{"parameters":{"descriptionType":"manual","toolDescription":"读本店的全部常见问题和标准答案(question 是问题,answer 是标准答案,keywords 是顾客可能的其他问法)。","operation":"get","returnAll":true,"dataTableId":{"__rl":true,"mode":"name","value":"常见问题"}},"id":"bbb8507a-4101-5eca-a4a4-7668d741ff33","name":"Query_FAQ","type":"n8n-nodes-base.dataTableTool","typeVersion":1.1,"position":[520,160]},{"parameters":{"descriptionType":"manual","toolDescription":"把顾客的问题转给店员:在待人工表里记一条。查不到答案、退款退换、投诉、质量问题、团购批发报价、要找真人时调用。","operation":"insert","dataTableId":{"__rl":true,"mode":"name","value":"待人工"},"columns":{"mappingMode":"defineBelow","value":{"question":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('question', `顾客的问题,用一句话概括`, 'string') }}","contact":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('contact', `顾客主动留下的手机号或微信号;没留就填「未留」`, 'string') }}","reason":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('reason', `转人工的原因:查不到 / 退换货 / 质量问题 / 投诉 / 团购报价 / 要找真人`, 'string') }}","session_id":"={{ $('预检和设置').item.json.sessionId }}","source":"AI 转人工","detail":"","status":"待处理"},"matchingColumns":[],"schema":[{"id":"question","displayName":"question","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"contact","displayName":"contact","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"reason","displayName":"reason","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"session_id","displayName":"session_id","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"source","displayName":"source","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"detail","displayName":"detail","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"status","displayName":"status","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"42f5e941-4977-5fc8-bdd4-f5d2415d213c","name":"Handoff_To_Human","type":"n8n-nodes-base.dataTableTool","typeVersion":1.1,"position":[660,160]},{"parameters":{"assignments":{"assignments":[{"id":"e1","name":"output","value":"【AI 回复】\nAI 客服暂时出了点问题,请过几分钟再试;急事请打店铺页面上的电话找店员。","type":"string"}]},"options":{}},"id":"08abf947-34f3-5ff5-bc7a-641eecd7f908","name":"出错时的回复","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[560,-320]},{"parameters":{"operation":"get","returnAll":true,"dataTableId":{"__rl":true,"mode":"name","value":"商品手册"}},"id":"c0b463c1-0956-5ecf-8d21-73b4cb75a5b4","name":"读商品手册","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[420,-160],"executeOnce":true,"alwaysOutputData":true},{"parameters":{"operation":"get","returnAll":true,"dataTableId":{"__rl":true,"mode":"name","value":"常见问题"}},"id":"f8bffafb-02be-5064-bf1c-b72ab228f158","name":"读常见问题","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[600,-160],"executeOnce":true,"alwaysOutputData":true},{"parameters":{"jsCode":"// 检查 AI 的回复:①前面加【AI 回复】②拦下打折、退款这类承诺 ③标出价目表里没有的金额 ④看有没有转人工\nconst agent = $('AI 客服').first().json;\nconst pre = $('预检和设置').first().json;\nlet reply = String(agent.output ?? agent.text ?? '').trim();\n\n// 商品手册和常见问题里出现过的数字、文字\nconst rows = [...$('读商品手册').all(), ...$('读常见问题').all()].map(i => i.json);\nconst tableText = rows.map(r => Object.values(r).join(' ')).join('\\n');\nconst known = new Set((tableText.match(/\\d+(\\.\\d+)?/g) || []).map(Number));\n\n// ② 承诺:程序认得出的常见说法(认不全,主要靠提示词和店员抽查)\nconst PROMISE = [\n /打\\s*[0-9一二三四五六七八九两]+(\\.\\d+)?\\s*折/,\n /(给|帮|替)(您|你)(办理|申请|安排)?(便宜|优惠|少算|减免|减|免单|抹零|退款|退钱|退货|退换|换货|补发|赔偿|补偿)/,\n /(包退|包赔|包换|保证退|保证赔|全额退款|直接退款|马上退款|免单|返现)/,\n /(送|赠)(您|你)(一|1|两|2|个|份|包|罐|盒|饼)/,\n];\n// 前面几个字里有「不、没、无法」的是在回绝(如「不能打八折」),不算承诺\nconst NEG = /(不|没|无法|没法|不能|不可以|不会)[^,。!?\\n]{0,4}$/;\nconst hit = [];\nfor (const re of PROMISE) {\n for (const m of reply.matchAll(new RegExp(re.source, 'g'))) {\n if (NEG.test(reply.slice(Math.max(0, m.index - 8), m.index))) continue;\n if (tableText.includes(m[0])) continue;\n hit.push(m[0]);\n }\n}\n\n// ③ 金额:¥123、123 元、123 块\nconst amounts = [...reply.matchAll(/(?:[¥¥]\\s*(\\d+(?:\\.\\d+)?))|(?:(\\d+(?:\\.\\d+)?)\\s*(?:元|块))/g)].map(m => Number(m[1] ?? m[2]));\nconst unknownAmounts = [...new Set(amounts.filter(a => !known.has(a)))];\n\n// ④ 转人工:看 AI 有没有调用 Handoff_To_Human\nconst steps = agent.intermediateSteps || [];\nconst handoffs = steps.filter(s => String(s.action?.tool || '').includes('Handoff')).map(s => s.action.toolInput || {});\n\nlet finalText = reply, logRow = null;\nif (hit.length) {\n finalText = '这个问题涉及优惠或售后,我不能直接答复,已经帮你转给店员。店员会在营业时间(每天 9:30–21:00)联系你;方便的话留下手机号或微信号。';\n logRow = { question: pre.chatInput, contact: '未留', reason: '回复被拦下:' + hit.join('、'), session_id: pre.sessionId,\n source: '程序拦下', detail: reply.slice(0, 500), status: '待处理' };\n} else if (unknownAmounts.length) {\n finalText = reply + `\\n\\n(${unknownAmounts.join('、')} 元是 AI 算出来的,价目表里没有这个数,下单以商品页为准。)`;\n}\n\nconst notify = Boolean(logRow) || handoffs.length > 0;\nconst h = handoffs[handoffs.length - 1] || {};\nconst notifyText = [`【${pre.shopName}】有顾客要转人工`,\n `顾客说:${pre.chatInput}`,\n logRow ? `原因:${logRow.reason}` : `原因:${h.reason ?? ''}`,\n `联系方式:${logRow ? '未留' : (h.contact ?? '未留')}`,\n '去 n8n 的 Data tables →「待人工」表里看详情'].join('\\n');\n\nreturn [{ json: { output: `【AI 回复】\\n${finalText}`, intercepted: hit, unknownAmounts, handoff: handoffs.length,\n notify, notifyText, logRow, wecomWebhook: pre.wecomWebhook } }];"},"id":"b3630b2b-17b8-504f-8151-2fe9ef173354","name":"检查回复","type":"n8n-nodes-base.code","typeVersion":2,"position":[780,-160]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"loose","version":2},"conditions":[{"id":"c2","leftValue":"={{ $json.logRow }}","rightValue":"","operator":{"type":"object","operation":"notEmpty","singleValue":true}}],"combinator":"and"},"options":{}},"id":"a74cc163-43fa-567a-970b-78f4e95468f6","name":"拦下了吗","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[980,-160]},{"parameters":{"operation":"insert","dataTableId":{"__rl":true,"mode":"name","value":"待人工"},"columns":{"mappingMode":"defineBelow","value":{"question":"={{ $json.logRow.question }}","contact":"={{ $json.logRow.contact }}","reason":"={{ $json.logRow.reason }}","session_id":"={{ $json.logRow.session_id }}","source":"={{ $json.logRow.source }}","detail":"={{ $json.logRow.detail }}","status":"={{ $json.logRow.status }}"},"matchingColumns":[],"schema":[{"id":"question","displayName":"question","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"contact","displayName":"contact","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"reason","displayName":"reason","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"session_id","displayName":"session_id","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"source","displayName":"source","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"detail","displayName":"detail","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"status","displayName":"status","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"42b0a77e-8b02-5eb9-92a2-d5d5d5fa0635","name":"记进待人工","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[1160,-320]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"loose","version":2},"conditions":[{"id":"c3","leftValue":"={{ $('检查回复').item.json.notify }}","rightValue":true,"operator":{"type":"boolean","operation":"true","singleValue":true}},{"id":"c4","leftValue":"={{ $('检查回复').item.json.wecomWebhook }}","rightValue":"","operator":{"type":"string","operation":"notEmpty","singleValue":true}}],"combinator":"and"},"options":{}},"id":"34cb9a01-e7a6-573c-abaa-8749dccd08aa","name":"要发提醒吗","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1340,-160]},{"parameters":{"method":"POST","url":"={{ $('检查回复').item.json.wecomWebhook }}","sendBody":true,"specifyBody":"json","jsonBody":"={{ JSON.stringify({ msgtype: 'text', text: { content: $('检查回复').item.json.notifyText } }) }}","options":{"timeout":10000}},"id":"7df71a31-108c-59cf-bb8e-747e0da40722","name":"企业微信提醒","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1520,-320],"onError":"continueRegularOutput"},{"parameters":{"assignments":{"assignments":[{"id":"r1","name":"output","value":"={{ $('检查回复').item.json.output }}","type":"string"}]},"options":{}},"id":"3d9b680a-a9d8-5485-aad9-125a900baf37","name":"回复顾客","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[1700,-160]},{"parameters":{},"id":"2a0baf0c-9896-5fb4-a962-9dc014b1d145","name":"第一次用:建表","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[-520,540]},{"parameters":{"resource":"table","operation":"create","tableName":"商品手册","columns":{"column":[{"name":"name","type":"string"},{"name":"category","type":"string"},{"name":"origin","type":"string"},{"name":"spec","type":"string"},{"name":"price","type":"number"},{"name":"taste","type":"string"},{"name":"brewing","type":"string"},{"name":"storage","type":"string"},{"name":"stock","type":"string"},{"name":"note","type":"string"}]},"options":{"createIfNotExists":true}},"id":"2d83283d-8d27-5037-a84c-730c0cf8c3d8","name":"建商品手册表","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[-300,540],"executeOnce":true},{"parameters":{"resource":"table","operation":"create","tableName":"常见问题","columns":{"column":[{"name":"question","type":"string"},{"name":"answer","type":"string"},{"name":"keywords","type":"string"}]},"options":{"createIfNotExists":true}},"id":"1b7c630f-22b2-5e42-90b7-66b685eb6b8a","name":"建常见问题表","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[-100,540],"executeOnce":true},{"parameters":{"resource":"table","operation":"create","tableName":"待人工","columns":{"column":[{"name":"question","type":"string"},{"name":"contact","type":"string"},{"name":"reason","type":"string"},{"name":"session_id","type":"string"},{"name":"source","type":"string"},{"name":"detail","type":"string"},{"name":"status","type":"string"}]},"options":{"createIfNotExists":true}},"id":"3f7700b8-58cc-5912-a34c-d839cbbb2800","name":"建待人工表","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[100,540],"executeOnce":true},{"parameters":{"jsCode":"// 示例:虚构的茶叶店,换成你自己的商品(也可以建好表后在 Data tables 里直接改)\nreturn [\n {\n \"name\": \"明前西湖龙井(一级)\",\n \"category\": \"绿茶\",\n \"origin\": \"浙江杭州\",\n \"spec\": \"100 克/罐\",\n \"price\": 268,\n \"taste\": \"豆香、鲜爽,回甘快\",\n \"brewing\": \"80–85℃ 水,玻璃杯放 3 克,注水 150 毫升,泡 2 分钟\",\n \"storage\": \"密封冷藏,保质期 18 个月\",\n \"stock\": \"有货\",\n \"note\": \"2026 年春茶,清明前采摘\"\n },\n {\n \"name\": \"安吉白茶\",\n \"category\": \"绿茶\",\n \"origin\": \"浙江安吉\",\n \"spec\": \"50 克×2 袋\",\n \"price\": 198,\n \"taste\": \"清甜、带鲜,氨基酸含量高\",\n \"brewing\": \"80℃ 水,3 克茶 150 毫升,泡 1–2 分钟\",\n \"storage\": \"密封冷藏,保质期 18 个月\",\n \"stock\": \"有货\",\n \"note\": \"虽然叫白茶,按工艺是绿茶\"\n },\n {\n \"name\": \"黄山毛峰\",\n \"category\": \"绿茶\",\n \"origin\": \"安徽黄山\",\n \"spec\": \"125 克/罐\",\n \"price\": 128,\n \"taste\": \"兰花香,滋味醇和\",\n \"brewing\": \"85℃ 水,3 克茶 150 毫升,泡 2 分钟\",\n \"storage\": \"密封冷藏,保质期 18 个月\",\n \"stock\": \"少量(剩 6 罐)\",\n \"note\": \"\"\n },\n {\n \"name\": \"正山小种\",\n \"category\": \"红茶\",\n \"origin\": \"福建武夷山桐木关\",\n \"spec\": \"150 克/罐\",\n \"price\": 158,\n \"taste\": \"松烟香,带桂圆味\",\n \"brewing\": \"95℃ 水,盖碗放 5 克,前三泡 10 秒出汤\",\n \"storage\": \"常温避光防潮,保质期 36 个月\",\n \"stock\": \"有货\",\n \"note\": \"传统烟熏工艺\"\n },\n {\n \"name\": \"滇红金芽\",\n \"category\": \"红茶\",\n \"origin\": \"云南凤庆\",\n \"spec\": \"100 克/罐\",\n \"price\": 138,\n \"taste\": \"蜜香,汤色金红\",\n \"brewing\": \"90–95℃ 水,盖碗放 5 克,10–15 秒出汤\",\n \"storage\": \"常温避光防潮,保质期 36 个月\",\n \"stock\": \"有货\",\n \"note\": \"\"\n },\n {\n \"name\": \"武夷岩茶·肉桂\",\n \"category\": \"乌龙茶\",\n \"origin\": \"福建武夷山\",\n \"spec\": \"8 克×20 泡/盒\",\n \"price\": 298,\n \"taste\": \"桂皮香,焙火足,岩韵明显\",\n \"brewing\": \"100℃ 沸水,盖碗一泡 8 克,前几泡 5–10 秒出汤\",\n \"storage\": \"常温避光防潮,保质期 36 个月\",\n \"stock\": \"有货\",\n \"note\": \"中足火\"\n },\n {\n \"name\": \"安溪铁观音(清香型)\",\n \"category\": \"乌龙茶\",\n \"origin\": \"福建安溪\",\n \"spec\": \"250 克/罐\",\n \"price\": 168,\n \"taste\": \"兰花香,汤色清绿\",\n \"brewing\": \"100℃ 沸水,盖碗放 7 克,前三泡 15 秒出汤\",\n \"storage\": \"密封冷藏,保质期 12 个月\",\n \"stock\": \"缺货,预计 12 月 10 日到货\",\n \"note\": \"\"\n },\n {\n \"name\": \"普洱熟茶饼(2019 年)\",\n \"category\": \"黑茶\",\n \"origin\": \"云南勐海\",\n \"spec\": \"357 克/饼\",\n \"price\": 238,\n \"taste\": \"陈香,醇厚顺滑\",\n \"brewing\": \"100℃ 沸水,先快速洗茶一次,盖碗放 7 克\",\n \"storage\": \"常温通风、避光防异味,可以长期存放\",\n \"stock\": \"有货\",\n \"note\": \"2019 年压制\"\n },\n {\n \"name\": \"福鼎白茶·寿眉(2021 年)\",\n \"category\": \"白茶\",\n \"origin\": \"福建福鼎\",\n \"spec\": \"300 克/饼\",\n \"price\": 178,\n \"taste\": \"枣香,越放越醇\",\n \"brewing\": \"可以煮着喝;冲泡用 100℃ 沸水,盖碗放 5 克\",\n \"storage\": \"常温避光防潮,可以长期存放\",\n \"stock\": \"有货\",\n \"note\": \"2021 年春茶压饼\"\n },\n {\n \"name\": \"桂花乌龙冷泡茶包\",\n \"category\": \"花草调味茶\",\n \"origin\": \"福建(乌龙茶拼配桂花)\",\n \"spec\": \"3 克×15 包/盒\",\n \"price\": 59,\n \"taste\": \"桂花香,清爽\",\n \"brewing\": \"一包放进 500 毫升凉白开或矿泉水,冰箱冷藏 4 小时\",\n \"storage\": \"常温避光防潮,保质期 12 个月\",\n \"stock\": \"有货\",\n \"note\": \"含桂花,对花粉过敏的顾客慎选\"\n }\n].map(json => ({ json }));"},"id":"6a25b229-2942-51e9-a08e-0eafd50aa24b","name":"示例商品","type":"n8n-nodes-base.code","typeVersion":2,"position":[300,540],"executeOnce":true},{"parameters":{"operation":"upsert","dataTableId":{"__rl":true,"mode":"name","value":"商品手册"},"filters":{"conditions":[{"keyName":"name","condition":"eq","keyValue":"={{ $json.name }}"}]},"columns":{"mappingMode":"autoMapInputData","value":{},"matchingColumns":[],"schema":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"b3b162dd-9325-5188-a642-941f1695218d","name":"写入示例商品","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[500,540]},{"parameters":{"jsCode":"// 示例:虚构茶叶店的常见问题\nreturn [\n {\n \"question\": \"怎么发货?几天能到?\",\n \"answer\": \"下午 4 点前付款的订单当天发货,4 点以后第二天发。默认发顺丰,江浙沪一般第二天到,其他地区 2–3 天;新疆、西藏、青海走 EMS,5–7 天。\",\n \"keywords\": \"发货时间、快递、物流、几天到、顺丰、偏远地区\"\n },\n {\n \"question\": \"包邮吗?运费多少?\",\n \"answer\": \"订单满 199 元包邮(新疆、西藏、青海除外);不满 199 元运费 12 元。新疆、西藏、青海每单运费 25 元。\",\n \"keywords\": \"包邮、运费、邮费、满多少包邮\"\n },\n {\n \"question\": \"能退换货吗?\",\n \"answer\": \"没拆封的商品,签收后 7 天内可以申请退换,来回运费由顾客承担。茶叶是食品,拆封后除了质量问题不退不换。觉得有质量问题,请拍下包装和茶叶的照片发给店员,由店员核实后处理。\",\n \"keywords\": \"退货、换货、退款、七天无理由、拆封、质量问题、售后\"\n },\n {\n \"question\": \"能便宜一点吗?有没有优惠?\",\n \"answer\": \"本店线上线下价格统一,不议价。节假日活动以店铺首页公告为准,客服不能单独改价。\",\n \"keywords\": \"砍价、打折、优惠、便宜、优惠券、活动\"\n },\n {\n \"question\": \"可以开发票吗?\",\n \"answer\": \"可以开电子普通发票。下单后把发票抬头和税号发给店员,3 个工作日内发到邮箱。\",\n \"keywords\": \"发票、报销、抬头、税号\"\n },\n {\n \"question\": \"有礼盒包装吗?适合送礼吗?\",\n \"answer\": \"有。礼盒每个加 30 元,能放 2 罐茶,附手提袋,可以免费帮写贺卡。下单时备注「要礼盒」和贺卡内容。\",\n \"keywords\": \"送礼、礼盒、礼品、包装、贺卡、送长辈\"\n },\n {\n \"question\": \"茶叶怎么保存?\",\n \"answer\": \"绿茶和清香型铁观音要密封冷藏;红茶、岩茶、白茶、普洱放在常温、避光、干燥、没有异味的地方。开封后尽量一个月内喝完。\",\n \"keywords\": \"保存、储存、冷藏、放冰箱、受潮\"\n },\n {\n \"question\": \"实体店在哪?营业时间?\",\n \"answer\": \"门店地址:XX 市 XX 路 XX 号(示例,换成你自己的地址)。每天 9:30–21:00 营业。\",\n \"keywords\": \"地址、门店、实体店、营业时间、几点开门\"\n },\n {\n \"question\": \"怎么找人工客服?\",\n \"answer\": \"人工客服每天 9:30–21:00 在线。可以在聊天里留下手机号或微信号,店员会在营业时间联系你。\",\n \"keywords\": \"人工、真人、客服电话、联系店员、投诉\"\n },\n {\n \"question\": \"能批发或者公司团购吗?\",\n \"answer\": \"同一款买 20 件以上算团购,价格由店员单独报价,请留下联系方式和需要的数量。\",\n \"keywords\": \"批发、团购、公司采购、大量购买、年货\"\n }\n].map(json => ({ json }));"},"id":"c9e53be4-d5a1-5d94-b894-31e578042b1e","name":"示例问答","type":"n8n-nodes-base.code","typeVersion":2,"position":[700,540],"executeOnce":true},{"parameters":{"operation":"upsert","dataTableId":{"__rl":true,"mode":"name","value":"常见问题"},"filters":{"conditions":[{"keyName":"question","condition":"eq","keyValue":"={{ $json.question }}"}]},"columns":{"mappingMode":"autoMapInputData","value":{},"matchingColumns":[],"schema":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"389e0d23-210f-51d8-b752-4b0dc720caaa","name":"写入示例问答","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[900,540]},{"parameters":{"formTitle":"录一条常见问题","formDescription":"录顾客常问的问题和标准答案,AI 客服下一条消息起就会用上。价格、退换规则请写准确,AI 会照着说。","formFields":{"values":[{"fieldLabel":"顾客常问的问题","fieldName":"question","requiredField":true,"placeholder":"例如:可以开发票吗?"},{"fieldLabel":"标准答案","fieldName":"answer","fieldType":"textarea","requiredField":true}]},"authentication":"n8nUserAuth","options":{"appendAttribution":false,"buttonLabel":"存进常见问题","respondWithOptions":{"values":{"formSubmittedText":"已存好。AI 客服下一条消息起就能用上。"}}}},"id":"19eebabd-bed7-5e71-b5a3-091b82c24c6b","name":"店员录问答","type":"n8n-nodes-base.formTrigger","typeVersion":2.5,"position":[-520,880]},{"parameters":{"promptType":"define","text":"=问题:{{ $json.question }}\n答案:{{ $json.answer }}","messages":{"messageValues":[{"message":"你帮一家网店整理客服知识库。看下面这条问题和答案,写出顾客还可能怎么问、会用到哪些词,4 到 8 个,用顿号隔开,只输出这一行,不要解释。\n例子:发货时间、几天到、快递、物流、顺丰"}]}},"id":"25c960fb-2028-55d6-abb2-76c0bc09033f","name":"AI 补几种问法","type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.7,"position":[-300,880]},{"parameters":{"model":{"__rl":true,"mode":"id","value":"deepseek-flash"},"responsesApiEnabled":false,"options":{"extraBody":"{\n \"thinking\": { \"type\": \"disabled\" }\n}"}},"id":"696a5baf-5f10-5415-a1d5-266859dcd15e","name":"模型(录问答用)","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.3,"position":[-300,1040]},{"parameters":{"operation":"upsert","dataTableId":{"__rl":true,"mode":"name","value":"常见问题"},"filters":{"conditions":[{"keyName":"question","condition":"eq","keyValue":"={{ $('店员录问答').item.json.question }}"}]},"columns":{"mappingMode":"defineBelow","value":{"question":"={{ $('店员录问答').item.json.question }}","answer":"={{ $('店员录问答').item.json.answer }}","keywords":"={{ $json.text.trim() }}"},"matchingColumns":[],"schema":[{"id":"question","displayName":"question","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"answer","displayName":"answer","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false},{"id":"keywords","displayName":"keywords","required":false,"defaultMatch":false,"display":true,"type":"string","readOnly":false,"removed":false}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"id":"3dafb791-321a-56ba-ae8a-f0994022160a","name":"存进常见问题","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[-60,880]}],"connections":{"顾客聊天入口":{"main":[[{"node":"预检和设置","type":"main","index":0}]]},"预检和设置":{"main":[[{"node":"放行吗","type":"main","index":0}]]},"放行吗":{"main":[[{"node":"AI 客服","type":"main","index":0}],[{"node":"拦下时的回复","type":"main","index":0}]]},"模型":{"ai_languageModel":[[{"node":"AI 客服","type":"ai_languageModel","index":0}]]},"对话记忆":{"ai_memory":[[{"node":"AI 客服","type":"ai_memory","index":0}]]},"Query_Products":{"ai_tool":[[{"node":"AI 客服","type":"ai_tool","index":0}]]},"Query_FAQ":{"ai_tool":[[{"node":"AI 客服","type":"ai_tool","index":0}]]},"Handoff_To_Human":{"ai_tool":[[{"node":"AI 客服","type":"ai_tool","index":0}]]},"AI 客服":{"main":[[{"node":"读商品手册","type":"main","index":0}],[{"node":"出错时的回复","type":"main","index":0}]]},"读商品手册":{"main":[[{"node":"读常见问题","type":"main","index":0}]]},"读常见问题":{"main":[[{"node":"检查回复","type":"main","index":0}]]},"检查回复":{"main":[[{"node":"拦下了吗","type":"main","index":0}]]},"拦下了吗":{"main":[[{"node":"记进待人工","type":"main","index":0}],[{"node":"要发提醒吗","type":"main","index":0}]]},"记进待人工":{"main":[[{"node":"要发提醒吗","type":"main","index":0}]]},"要发提醒吗":{"main":[[{"node":"企业微信提醒","type":"main","index":0}],[{"node":"回复顾客","type":"main","index":0}]]},"企业微信提醒":{"main":[[{"node":"回复顾客","type":"main","index":0}]]},"第一次用:建表":{"main":[[{"node":"建商品手册表","type":"main","index":0}]]},"建商品手册表":{"main":[[{"node":"建常见问题表","type":"main","index":0}]]},"建常见问题表":{"main":[[{"node":"建待人工表","type":"main","index":0}]]},"建待人工表":{"main":[[{"node":"示例商品","type":"main","index":0}]]},"示例商品":{"main":[[{"node":"写入示例商品","type":"main","index":0}]]},"写入示例商品":{"main":[[{"node":"示例问答","type":"main","index":0}]]},"示例问答":{"main":[[{"node":"写入示例问答","type":"main","index":0}]]},"店员录问答":{"main":[[{"node":"AI 补几种问法","type":"main","index":0}]]},"模型(录问答用)":{"ai_languageModel":[[{"node":"AI 补几种问法","type":"ai_languageModel","index":0}]]},"AI 补几种问法":{"main":[[{"node":"存进常见问题","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","timezone":"Asia/Shanghai","saveManualExecutions":true},"pinData":{},"meta":{"templateCredsSetupCompleted":false}}
下载后在 n8n、Dify 里导入;n8n 也可以直接在画布上按 Ctrl+V 粘贴。