使用Jotform、Supabase上的RAG、Together AI和Gemini构建知识库聊天机器人
中级
这是一个自动化工作流,包含 15 个节点。主要使用 Code, Supabase, Aggregate, HttpRequest, JotFormTrigger 等节点。 使用Jotform、Supabase上的RAG、Together AI和Gemini构建知识库聊天机器人
前置要求
- •Supabase URL 和 API Key
- •可能需要目标 API 的认证凭证
- •Google Gemini API Key
使用的节点 (15)
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "93f396852104089b8670e7494b0f3668b420464668ae4a8c1d6b4b5799f8e3ef",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "1c57da69-7af2-47c8-8bc2-92e49449bd81",
"name": "分块处理",
"type": "n8n-nodes-base.code",
"position": [
2192,
-496
],
"parameters": {
"jsCode": "const text = $input.first().json.text;\nconst chunkSize = 1000;\n\nlet chunks = [];\nfor (let i = 0; i < text.length; i += chunkSize) {\n chunks.push({\n json: { chunk: text.slice(i, i + chunkSize) }\n });\n}\n\nreturn chunks;\n\n"
},
"typeVersion": 2
},
{
"id": "d5ed1aaf-6089-4731-980d-b5c356b22403",
"name": "嵌入上传文档",
"type": "n8n-nodes-base.httpRequest",
"position": [
2416,
-496
],
"parameters": {
"url": "https://api.together.xyz/v1/embeddings",
"method": "POST",
"options": {},
"sendBody": true,
"sendHeaders": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "BAAI/bge-large-en-v1.5"
},
{
"name": "input",
"value": "={{ $json.chunk }}"
}
]
},
"genericAuthType": "httpBearerAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "ePx2TlbqIiRjDGfW",
"name": "Together API"
}
},
"typeVersion": 4.2
},
{
"id": "0b1c609f-e335-4541-8dae-e3517ec4bb63",
"name": "将嵌入保存到数据库",
"type": "n8n-nodes-base.supabase",
"position": [
2624,
-496
],
"parameters": {
"tableId": "RAG",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "chunk",
"fieldValue": "={{ $('Splitting into Chunks').item.json.chunk }}"
},
{
"fieldId": "embeddings",
"fieldValue": "={{ JSON.stringify($json.data[0].embedding) }}"
}
]
}
},
"credentials": {
"supabaseApi": {
"id": "sNLLVD1n1FkMp81B",
"name": "abhi.vaar"
}
},
"typeVersion": 1
},
{
"id": "3a39d174-434e-4c81-921c-8a354fad5ebe",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
2064,
64
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "chunk"
}
]
}
},
"typeVersion": 1
},
{
"id": "4ce2ab5b-bb1e-46ce-9dd8-2cfdee5510a2",
"name": "搜索嵌入",
"type": "n8n-nodes-base.httpRequest",
"position": [
1840,
64
],
"parameters": {
"url": "https://enter-your-supabase-host/rest/v1/rpc/matchembeddings1",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "=query_embedding",
"value": "={{ $json.data[0].embedding }}"
},
{
"name": "match_count",
"value": "5"
}
]
},
"nodeCredentialType": "supabaseApi"
},
"credentials": {
"supabaseApi": {
"id": "sNLLVD1n1FkMp81B",
"name": "abhi.vaar"
}
},
"typeVersion": 4.2
},
{
"id": "76c8df3f-cf64-4848-b077-d04e9de88d12",
"name": "嵌入用户消息",
"type": "n8n-nodes-base.httpRequest",
"position": [
1616,
64
],
"parameters": {
"url": "https://api.together.xyz/v1/embeddings",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "BAAI/bge-large-en-v1.5"
},
{
"name": "input",
"value": "={{ $json.chatInput }}"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "ePx2TlbqIiRjDGfW",
"name": "Together API"
}
},
"typeVersion": 4.2
},
{
"id": "d8dba80c-597e-470b-852b-6d53363238bc",
"name": "Google Gemini 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
2272,
288
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "qsaK3VMNWQDWLweQ",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "f74c0006-15e0-4f48-8c02-b0b765154c5b",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2272,
64
],
"parameters": {
"text": "=You are a helpful and professional customer support agent. Use the following context to answer the user's question. \n\nHandle greetings without the need of the context...\n\nContext:\n{{ $json.chunk }}\n\nUser's message:\n{{ $('When chat message received').item.json.chatInput }}\n\nFormat your reply in WhatsApp style:\n- Use _italics_ for emphasis\n- Use *bold* for key points\n- Use • for bullet lists (no markdown dashes or hashes)\n- Keep responses short, clear, and conversational, like real WhatsApp support\n- Avoid markdown headers or code blocks\n\nGive a clear, accurate, and friendly response based only on the context. \nIf the answer cannot be found in the context, reply: _\"I don't know based on the provided information.\"_\n",
"options": {},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "81c63733-c5c8-4a4d-b634-e3d93d9bb1c6",
"name": "从PDF文件提取文本",
"type": "n8n-nodes-base.extractFromFile",
"position": [
2000,
-496
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "490c541e-fae8-4965-9840-9e13d562acdd",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
1392,
64
],
"webhookId": "2032c492-7d92-4d79-b545-5e0b9807253f",
"parameters": {
"options": {}
},
"typeVersion": 1.3
},
{
"id": "8add4f5e-d2f8-4ea8-a6e1-6d4912d60393",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
-768
],
"parameters": {
"width": 1584,
"height": 512,
"content": "### 第1部分:为AI提供知识(\"图书管理员\"部分)"
},
"typeVersion": 1
},
{
"id": "d764c67f-cca8-476e-8d63-78d2733f6b64",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
-208
],
"parameters": {
"width": 1600,
"height": 656,
"content": "---"
},
"typeVersion": 1
},
{
"id": "d1f68d16-6baa-4420-8606-dbc7ca5791c7",
"name": "JotForm 触发器",
"type": "n8n-nodes-base.jotFormTrigger",
"position": [
1376,
-496
],
"webhookId": "52c8e2e7-7277-4dfd-8336-c3857f945102",
"parameters": {
"form": "252862840518058",
"onlyAnswers": false
},
"credentials": {
"jotFormApi": {
"id": "4612J1BsqtC505ac",
"name": "secondary"
}
},
"typeVersion": 1
},
{
"id": "8f035b6b-c3c0-449a-acb4-0c359c309e32",
"name": "获取新知识库",
"type": "n8n-nodes-base.httpRequest",
"position": [
1584,
-496
],
"parameters": {
"url": "=https://api.jotform.com/submission/{{ $json.submissionID }}?apiKey=enter-your-jotfomr-api",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "b826edc5-d97f-498c-bea1-b3f3d1430635",
"name": "获取上传的知识库文件链接",
"type": "n8n-nodes-base.httpRequest",
"position": [
1792,
-496
],
"parameters": {
"url": "={{ $json.content.answers['6'].answer[0] }}",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "APIKEY",
"value": "enter-your-jotfomr-api"
}
]
}
},
"typeVersion": 4.2
}
],
"pinData": {},
"connections": {
"AI Agent": {
"main": [
[]
]
},
"Aggregate": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"JotForm Trigger": {
"main": [
[
{
"node": "Grab New knowledgebase",
"type": "main",
"index": 0
}
]
]
},
"Search Embeddings": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Embend User Message": {
"main": [
[
{
"node": "Search Embeddings",
"type": "main",
"index": 0
}
]
]
},
"Splitting into Chunks": {
"main": [
[
{
"node": "Embedding Uploaded document",
"type": "main",
"index": 0
}
]
]
},
"Grab New knowledgebase": {
"main": [
[
{
"node": "Grab the uploaded knowledgebase file link",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Extract Text from PDF File": {
"main": [
[
{
"node": "Splitting into Chunks",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Embend User Message",
"type": "main",
"index": 0
}
]
]
},
"Embedding Uploaded document": {
"main": [
[
{
"node": "Save the embedding in DB",
"type": "main",
"index": 0
}
]
]
},
"Grab the uploaded knowledgebase file link": {
"main": [
[
{
"node": "Extract Text from PDF File",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用RAG、Gemini、Supabase和Google Docs构建基于知识的WhatsApp助手
使用RAG、Gemini、Supabase和Google Docs构建基于知识的WhatsApp助手
If
Code
Supabase
+9
15 节点iamvaar
内容创作
AI驱动的NDA审核与即时警报系统 - JotForm、Gemini、Telegram
基于JotForm、Gemini和Telegram的AI驱动NDA审核与即时警报系统
Telegram
Http Request
Jot Form Trigger
+4
13 节点iamvaar
使用Supabase + TogetherAI + Openrouter的RAG聊天机器人
使用Supabase + TogetherAI + Openrouter的RAG聊天机器人
Code
Supabase
Aggregate
+7
13 节点iamvaar
内部知识库
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG 检索增强
使用Gemini AI自动化缺陷报告:Jotform到GitHub并发送Telegram提醒
使用Gemini AI自动化缺陷报告:Jotform到GitHub并发送Telegram提醒
Code
Telegram
Github Tool
+6
10 节点iamvaar