动态GDPR合规模型选择器与Requesty
高级
这是一个Engineering, AI Chatbot领域的自动化工作流,包含 20 个节点。主要使用 N8n, Set, Code, Merge, SplitOut 等节点。 通过Requesty和Google Sheets实现GDPR合规的动态AI模型选择器
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (20)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "xUuPJFkQw5aJ9Bfg",
"meta": {
"instanceId": "7f03117cd0731766b3ae8ea65a9638f11161d03d7cfb20d1531642698c9d0de3"
},
"name": "动态 GDPR 合规模型选择器与 Requesty",
"tags": [],
"nodes": [
{
"id": "fb6de8aa-2c8f-488e-8002-7aeb96861b3d",
"name": "初始化工作流",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-180,
-1140
],
"parameters": {},
"typeVersion": 1
},
{
"id": "5f73d2cb-368a-4ca6-af4a-7e97176b35c0",
"name": "获取可用模型",
"type": "n8n-nodes-base.httpRequest",
"position": [
40,
-1040
],
"parameters": {
"url": "https://router.requesty.ai/v1/models?provider=coding",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "63d190c6-ac9d-41e7-8e36-a1a045c5cc13",
"name": "分割模型数据",
"type": "n8n-nodes-base.splitOut",
"position": [
260,
-1040
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "data"
},
"typeVersion": 1
},
{
"id": "f95eb1c6-b6d7-492d-822c-02bc000c6749",
"name": "提取模型 ID",
"type": "n8n-nodes-base.set",
"position": [
480,
-1040
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "be11b412-dfb1-47fd-be24-e8dead708405",
"name": "id",
"type": "string",
"value": "={{ $json.data.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "b9595c92-7e9a-4688-aa12-bf558af42481",
"name": "获取当前工作流",
"type": "n8n-nodes-base.n8n",
"position": [
480,
-1240
],
"parameters": {
"operation": "get",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"requestOptions": {}
},
"executeOnce": true,
"typeVersion": 1
},
{
"id": "d8b903d3-53ec-47fd-9dfa-bdb131dae3bf",
"name": "合并数据",
"type": "n8n-nodes-base.merge",
"position": [
700,
-1140
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "bc7dde1f-0afd-47c9-a851-ded2ceb37dbf",
"name": "更新下拉选项",
"type": "n8n-nodes-base.code",
"position": [
920,
-1140
],
"parameters": {
"jsCode": "// n8n Code Node - Update Form Dropdown Options\n// First item = Workflow JSON, From second item = New Model IDs\n\ntry {\n // Get all input items\n const allInputs = $input.all();\n \n // First item is the workflow\n const workflowData = allInputs[0]?.json;\n \n // From second item onwards are the new model IDs\n const newOptions = [];\n \n // Iterate through all items from index 1\n for (let i = 1; i < allInputs.length; i++) {\n const item = allInputs[i];\n \n // Extract ID from the json object\n if (item?.json?.id) {\n newOptions.push(item.json.id);\n }\n }\n \n // Fallback if no IDs found\n if (newOptions.length === 0) {\n newOptions.push('No models available');\n }\n \n // Copy and modify workflow\n const result = JSON.parse(JSON.stringify(workflowData));\n \n // Go through workflow nodes\n if (result.nodes) {\n result.nodes.forEach(node => {\n if (node.type === 'n8n-nodes-base.formTrigger' && \n node.parameters?.formFields?.values) {\n \n node.parameters.formFields.values.forEach(field => {\n if (field.fieldType === 'dropdown' && field.fieldOptions) {\n // Set new dropdown options\n field.fieldOptions.values = newOptions.map(option => ({ option }));\n }\n });\n }\n });\n }\n \n return result;\n \n} catch (error) {\n // Error handling with debug info\n return {\n error: error.message,\n totalInputs: $input.all().length,\n sampleIds: $input.all().slice(1, 4).map(item => item?.json?.id),\n fallback: $input.first()?.json\n };\n}"
},
"typeVersion": 2
},
{
"id": "f672fce1-7081-4fd1-a898-dddabe38f853",
"name": "更新工作流",
"type": "n8n-nodes-base.n8n",
"position": [
1140,
-1140
],
"parameters": {
"operation": "update",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"requestOptions": {},
"workflowObject": "={{ JSON.stringify($json) }}"
},
"typeVersion": 1
},
{
"id": "6e12465c-2848-40fc-a1f8-ae2585d5882d",
"name": "模型选择表单",
"type": "n8n-nodes-base.formTrigger",
"position": [
-180,
-780
],
"webhookId": "a9562558-7962-4a3a-8b3f-82e5ba5bef1a",
"parameters": {
"options": {},
"formTitle": "Select AI Model",
"formFields": {
"values": [
{
"fieldType": "dropdown",
"fieldLabel": "AI Language Model",
"fieldOptions": {
"values": [
{}
]
}
}
]
}
},
"typeVersion": 2.2
},
{
"id": "fa81a3f1-0f28-4049-b6b2-f6f486e67e0d",
"name": "设置选定模型",
"type": "n8n-nodes-base.set",
"position": [
40,
-780
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "a132682c-fbbb-4abc-bdde-be93bf0cb992",
"name": "model",
"type": "string",
"value": "={{ $json.fieldName }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "0196af9b-aa3d-45bd-a6f1-92f96486ced9",
"name": "聊天界面",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-180,
-520
],
"webhookId": "47d7c77b-1904-4d17-ba39-a1d5b85069be",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "6191c42f-ece1-421d-b9cf-c9ab213f2f36",
"name": "AI API 请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
480,
-520
],
"parameters": {
"url": "https://router.requesty.ai/v1/chat/completions",
"method": "POST",
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
},
"jsonBody": "={\n \"model\": \"{{ $json.model }}\",\n \"messages\": [\n { \"role\": \"system\", \"content\": \"You are a helpful assistant.\" },\n { \"role\": \"user\", \"content\": \"{{ $('Chat Interface').item.json.chatInput }}\" }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.7\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer {{ $credentials.requestyApi.apiKey }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "ebcd8d4f-4d15-4755-971e-14a932adda23",
"name": "提取响应",
"type": "n8n-nodes-base.set",
"position": [
700,
-520
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f1ec57e7-d781-406f-b6ea-68906c679a2e",
"name": "content",
"type": "string",
"value": "={{ $json.choices[0].message.content }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "0ced2b03-0d09-474a-be65-2f49ddcf95fa",
"name": "获取当前模型",
"type": "n8n-nodes-base.set",
"position": [
260,
-520
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6470970a-10ce-4bc4-8fd0-de4c4e309e2d",
"name": "model",
"type": "string",
"value": "={{ $json.model }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7379d69a-9066-48be-a163-fea478bb2cef",
"name": "保存模型选择",
"type": "n8n-nodes-base.googleSheets",
"position": [
480,
-780
],
"parameters": {
"columns": {
"value": {},
"schema": [],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Current_Model"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.6
},
{
"id": "b8a03a91-5839-46e4-891c-e9793738f3dc",
"name": "清除先前选择",
"type": "n8n-nodes-base.googleSheets",
"position": [
260,
-780
],
"parameters": {
"operation": "clear",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Current_Model"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.6
},
{
"id": "58bc8a11-7f9e-452a-ad0f-d05f3c56eda9",
"name": "读取当前模型",
"type": "n8n-nodes-base.googleSheets",
"position": [
40,
-520
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Current_Model"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.6
},
{
"id": "9bcf3d2d-f320-44af-8c02-62b50a41a299",
"name": "AI 代理(可选)",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
40,
-240
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "32c0a603-b40e-4830-ab8d-592bcd3d9c58",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
40,
20
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "openai/gpt-4o-mini",
"cachedResultName": "openai/gpt-4o-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "fb9667d4-2b39-4ba5-b67a-d3671f814124",
"name": "格式化响应",
"type": "n8n-nodes-base.code",
"position": [
920,
-520
],
"parameters": {
"jsCode": "return [{\n json: {\n text: $json.content\n }\n}];\n"
},
"typeVersion": 2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "e65bf989-9806-4cc5-9f6d-e4fafa7883c7",
"connections": {
"Merge Data": {
"main": [
[
{
"node": "Update Dropdown Options",
"type": "main",
"index": 0
}
]
]
},
"AI API Request": {
"main": [
[
{
"node": "Extract Response",
"type": "main",
"index": 0
}
]
]
},
"Chat Interface": {
"main": [
[
{
"node": "Read Current Model",
"type": "main",
"index": 0
}
]
]
},
"Extract Response": {
"main": [
[
{
"node": "Format Response",
"type": "main",
"index": 0
}
]
]
},
"Split Model Data": {
"main": [
[
{
"node": "Extract Model IDs",
"type": "main",
"index": 0
}
]
]
},
"Extract Model IDs": {
"main": [
[
{
"node": "Merge Data",
"type": "main",
"index": 1
}
]
]
},
"Get Current Model": {
"main": [
[
{
"node": "AI API Request",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent (Optional)",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Read Current Model": {
"main": [
[
{
"node": "Get Current Model",
"type": "main",
"index": 0
}
]
]
},
"Set Selected Model": {
"main": [
[
{
"node": "Clear Previous Selection",
"type": "main",
"index": 0
}
]
]
},
"Initialize Workflow": {
"main": [
[
{
"node": "Get Current Workflow",
"type": "main",
"index": 0
},
{
"node": "Fetch Available Models",
"type": "main",
"index": 0
}
]
]
},
"Get Current Workflow": {
"main": [
[
{
"node": "Merge Data",
"type": "main",
"index": 0
}
]
]
},
"Model Selection Form": {
"main": [
[
{
"node": "Set Selected Model",
"type": "main",
"index": 0
}
]
]
},
"Fetch Available Models": {
"main": [
[
{
"node": "Split Model Data",
"type": "main",
"index": 0
}
]
]
},
"Update Dropdown Options": {
"main": [
[
{
"node": "Update Workflow",
"type": "main",
"index": 0
}
]
]
},
"Clear Previous Selection": {
"main": [
[
{
"node": "Save Model Selection",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工程, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能
使用Google Maps、GPT-4和WhatsApp自动化商业合作伙伴拓展
使用Google Maps、GPT-4和WhatsApp自动化商业合作伙伴拓展
If
Set
Code
+23
64 节点Khairul Muhtadin
AI 聊天机器人
基于Voyage-Context-3嵌入和MongoDB Atlas的文档问答系统
基于Voyage-Context-3嵌入和MongoDB Atlas的文档问答系统
Set
Code
Wait
+18
53 节点Jimleuk
工程
使用OpenAI和RAGAS方法评估AI代理响应正确性
使用OpenAI和RAGAS方法评估AI代理响应正确性
Set
Code
Merge
+12
27 节点Jimleuk
工程
评估指标:答案相似度
评估指标:答案相似度
Set
Code
Merge
+10
21 节点Jimleuk
工程