使用 OpenAI 嵌入的 BigQuery RAG
高级
这是一个Miscellaneous, AI RAG, Multimodal AI领域的自动化工作流,包含 24 个节点。主要使用 Set, HttpRequest, Agent, ChatTrigger, LmChatOpenAi 等节点。 使用 BigQuery RAG 和 OpenAI 回答文档相关问题
前置要求
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (24)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "",
"meta": {
"instanceId": ""
},
"name": "使用 OpenAI 嵌入的 BigQuery RAG",
"tags": [],
"nodes": [
{
"id": "69f19613-1e74-43dc-9f2e-c95c2db385e3",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-960,
64
],
"parameters": {
"options": {
"systemMessage": "You are an assistant specialized in answering questions about **n8n**. \nUse the connected vector store to retrieve relevant documentation and generate clear, structured, and helpful answers.\n\n## Instructions\n\n1. **Document Retrieval** \n - Query the connected vector store to gather information from the n8n documentation. \n - Base every answer on the retrieved content. \n\n2. **Answer Formatting** \n - Write all answers in **Markdown**. \n - Structure responses with clear sections, bullet points, or lists when useful. \n - Provide direct excerpts or explanations from the retrieved documents. \n\n3. **Images** \n - Include screenshots from the documentation when they provide value to the user. \n - Use Markdown syntax for images. \n - Focus on images that illustrate functionality or clarify instructions. \n\n4. **Code** \n - Present code snippets as **Markdown code blocks**. \n - Preserve the original content of the snippet. \n - Add language hints when available (e.g., ` ```javascript `). \n\n5. **Completeness** \n - Provide accurate, context-aware answers. \n - Indicate clearly when the retrieved documents do not contain enough information. "
}
},
"typeVersion": 2.2
},
{
"id": "e198291b-f8b0-455e-8c40-bf5a9cadef70",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-1408,
64
],
"webhookId": "dc7d2421-f489-4eea-b3fb-6b69ede9beed",
"parameters": {
"options": {}
},
"typeVersion": 1.3
},
{
"id": "53c039bc-4788-49f3-afc8-354498da9e44",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1152,
400
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "",
"name": "OpenAi Account"
}
},
"typeVersion": 1.2
},
{
"id": "e9a99d6d-e191-4ecf-a271-1a9ebb07e02a",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-848,
400
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "8acb8e42-c6e3-4254-a53d-077bbf9f4065",
"name": "当由其他工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-1488,
1264
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "vector_search_question"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "c97a255c-3328-4837-bf45-7a3f5cc7c5b7",
"name": "BigQuery RAG OpenAI",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
-512,
384
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "7tqwzCyxnnu8Svq3",
"cachedResultName": "BigQuery RAG With OpenAI Embedding"
},
"description": "调用此工具从向量数据库获取文档",
"workflowInputs": {
"value": {
"vector_search_question": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('vector_search_question', `A natural language question used to query the vector database containing the documentation.\n`, 'string') }}"
},
"schema": [
{
"id": "vector_search_question",
"type": "string",
"display": true,
"required": false,
"displayName": "vector_search_question",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"vector_search_question"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "dde0a97a-4495-42c2-837d-f5596f2bfbfe",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1536,
-128
],
"parameters": {
"color": 3,
"width": 384,
"height": 432,
"content": "## 当收到聊天消息时"
},
"typeVersion": 1
},
{
"id": "62bfaf5a-5b7f-430d-9bf6-c1d745e6a2c3",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1120,
-128
],
"parameters": {
"color": 7,
"width": 544,
"height": 432,
"content": "## AI 智能体"
},
"typeVersion": 1
},
{
"id": "dc49cd0c-3b52-475c-a423-7d8fd3914b4c",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1248,
368
],
"parameters": {
"color": 7,
"width": 288,
"height": 480,
"content": "## OpenAI 聊天模型"
},
"typeVersion": 1
},
{
"id": "5a6c7c06-2021-4ad3-9e16-482e230b298d",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
368
],
"parameters": {
"color": 7,
"width": 288,
"height": 480,
"content": "## 简单记忆"
},
"typeVersion": 1
},
{
"id": "7257c13a-e3f1-4602-807a-2ade1b14bcfc",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-608,
368
],
"parameters": {
"color": 7,
"width": 288,
"height": 480,
"content": "## BigQuery RAG OpenAI"
},
"typeVersion": 1
},
{
"id": "3d718a18-8cb5-4a8b-b968-fb58502852bb",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1568,
912
],
"parameters": {
"color": 3,
"width": 288,
"height": 512,
"content": "## 由其他工作流执行时"
},
"typeVersion": 1
},
{
"id": "a61ba929-9efc-404e-8457-39c273aeaeb6",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1248,
912
],
"parameters": {
"color": 7,
"width": 288,
"height": 512,
"content": "## 设置字段 - 问题"
},
"typeVersion": 1
},
{
"id": "14298572-7b25-4d0a-8360-8f36c5d3ee0e",
"name": "设置字段 - 问题",
"type": "n8n-nodes-base.set",
"position": [
-1152,
1264
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5635b058-5ab3-49fc-be4c-51bfc07630c7",
"name": "question",
"type": "string",
"value": "={{ $json.vector_search_question }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7166cd84-5c7b-4e10-aa40-d919c9f6387d",
"name": "OpenAI - 创建嵌入",
"type": "n8n-nodes-base.httpRequest",
"position": [
-832,
1264
],
"parameters": {
"url": "https://api.openai.com/v1/embeddings",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "input",
"value": "={{ $json.question }}"
},
{
"name": "model",
"value": "text-embedding-3-large"
}
]
},
"nodeCredentialType": "openAiApi"
},
"credentials": {
"openAiApi": {
"id": "",
"name": "OpenAi Account"
}
},
"typeVersion": 4.2
},
{
"id": "00247057-0cc0-4216-b299-115d9637c8b7",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
912
],
"parameters": {
"color": 7,
"width": 288,
"height": 512,
"content": "## OpenAI – 创建嵌入"
},
"typeVersion": 1
},
{
"id": "c6517110-de28-475c-82eb-d109ed99501c",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-608,
912
],
"parameters": {
"color": 7,
"width": 288,
"height": 512,
"content": "## 设置字段 – 嵌入"
},
"typeVersion": 1
},
{
"id": "79a780d1-8646-4927-93be-54168d920f85",
"name": "BigQuery - 向量检索器 - n8n 文档",
"type": "n8n-nodes-base.httpRequest",
"position": [
0,
1264
],
"parameters": {
"url": "https://bigquery.googleapis.com/bigquery/v2/projects/<YOUR-PROJECT-ID>/queries",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "query",
"value": "=WITH query AS (\n SELECT ARRAY(\n SELECT CAST(x AS FLOAT64)\n FROM UNNEST([{{ $json.embedding.join(',') }}]) AS x\n ) AS embedding\n)\nSELECT\n t.base.text,\n t.base.metadata,\n t.distance AS cosine_distance\nFROM VECTOR_SEARCH(\n TABLE `n8n-docs-rag.n8n_docs.n8n_docs_embeddings`,\n 'embedding',\n TABLE query,\n top_k => 10,\n distance_type => 'COSINE',\n options => '{\"use_brute_force\": true}'\n) AS t\nORDER BY t.distance;"
},
{
"name": "useLegacySql",
"value": "false"
}
]
},
"nodeCredentialType": "googleBigQueryOAuth2Api"
},
"credentials": {
"googleBigQueryOAuth2Api": {
"id": "",
"name": "Google BigQuery account"
}
},
"typeVersion": 4.2
},
{
"id": "32f2544c-8e36-41a3-97c4-f6264d418be6",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-288,
912
],
"parameters": {
"color": 7,
"width": 736,
"height": 512,
"content": "## BigQuery – 向量检索器 – n8n 文档"
},
"typeVersion": 1
},
{
"id": "bb368d56-96a4-4bf0-b3bc-703354258d1d",
"name": "已检索文档",
"type": "n8n-nodes-base.set",
"position": [
576,
1264
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "3a887578-7e34-4406-b44a-17695e5b5ab4",
"name": "documents",
"type": "string",
"value": "={{ $json.rows.toJsonString() }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "1523c1b9-e81e-4c11-87dc-f67a687965e5",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
912
],
"parameters": {
"color": 7,
"width": 288,
"height": 512,
"content": "## 已检索文档"
},
"typeVersion": 1
},
{
"id": "3f7c43ba-b4f1-4284-a896-c320769b9a2a",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
-288,
1440
],
"parameters": {
"color": 5,
"width": 736,
"height": 752,
"content": "## BigQuery – 向量检索器 – n8n 文档"
},
"typeVersion": 1
},
{
"id": "5da46a82-d97a-4c8b-8f3a-51286c677a1a",
"name": "便签 12",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2928,
-128
],
"parameters": {
"color": 7,
"width": 1344,
"height": 1200,
"content": "# 使用 OpenAI 嵌入的 BigQuery RAG"
},
"typeVersion": 1
},
{
"id": "92d2b05f-e8a3-4c64-ab65-4c64a2bc0297",
"name": "设置字段 - 嵌入",
"type": "n8n-nodes-base.set",
"position": [
-512,
1264
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "8abb7285-f4e4-46d7-a660-cd75104d8bbd",
"name": "embedding",
"type": "array",
"value": "={{ $json.data[0].embedding }}"
}
]
}
},
"typeVersion": 3.4
}
],
"active": false,
"pinData": {
"When Executed by Another Workflow": [
{
"json": {
"vector_search_question": "How does the n8n Webhook Trigger work?"
}
}
]
},
"settings": {
"executionOrder": "v1"
},
"versionId": "",
"connections": {
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"BigQuery RAG OpenAI": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Set field - question": {
"main": [
[
{
"node": "OpenAI - Create Embedding",
"type": "main",
"index": 0
}
]
]
},
"Set Field - Embedding": {
"main": [
[
{
"node": "BigQuery - Vector Retriever - n8n docs",
"type": "main",
"index": 0
}
]
]
},
"OpenAI - Create Embedding": {
"main": [
[
{
"node": "Set Field - Embedding",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Set field - question",
"type": "main",
"index": 0
}
]
]
},
"BigQuery - Vector Retriever - n8n docs": {
"main": [
[
{
"node": "Documents retrieved",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 杂项, AI RAG 检索增强, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG 检索增强
构建基于Supabase和GPT-5的高级多查询RAG系统
构建基于Supabase和GPT-5的高级多查询RAG系统
If
Set
Filter
+13
22 节点Guillaume Duvernay
AI RAG 检索增强
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
内容创作
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
使用GPT-4o为6个平台生成平台优化的社交媒体内容
If
Set
Code
+20
100 节点Luan Correia
社交媒体
多源采集
网络研究助手:基于Gemini AI的自动化搜索和抓取,生成电子表格报告
Set
Code
Http Request
+7
23 节点franck fambou
杂项
使用 VAPI 构建 AI 语音助手
WooCommerce AI语音客服,使用VAPI、GPT-4o、Gemini和RAG
Set
Webhook
Http Request
+13
25 节点Davide
杂项
工作流信息
难度等级
高级
节点数量24
分类3
节点类型9
作者
Dataki
@datakiI am passionate about transforming complex processes into seamless automations with n8n. My expertise spans across creating ETL pipelines, sales automations, and data & AI-driven workflows. As an avid problem solver, I thrive on optimizing workflows to drive efficiency and innovation.
外部链接
在 n8n.io 查看 →
分享此工作流