使用Google Sheets的REST API
高级
这是一个Engineering, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Set, Webhook, GoogleSheets, RespondToWebhook 等节点。 使用Google Sheets数据库创建CRUD REST API
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "6QvxWwgaPghd06wj",
"meta": {
"instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002",
"templateCredsSetupCompleted": true
},
"name": "使用 Google Sheets 的 REST API",
"tags": [],
"nodes": [
{
"id": "4b53d6ea-e083-4d89-b8af-6c4e37e4066e",
"name": "在表格中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
224,
0
],
"parameters": {
"columns": {
"value": {
"name": "={{ $json.body.name }}",
"email": "={{ $json.body.email }}",
"status": "={{ $json.body.status }}"
},
"schema": [
{
"id": "name",
"type": "string",
"display": true,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email",
"type": "string",
"display": true,
"required": false,
"displayName": "email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "string",
"display": true,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk",
"cachedResultName": "REST API data"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "FboA3kaXSneJmEGX",
"name": "Google Service Account account"
}
},
"typeVersion": 4.7
},
{
"id": "70a88ee3-83ef-409f-b9fc-699b57aff26a",
"name": "Webhook:创建",
"type": "n8n-nodes-base.webhook",
"position": [
0,
0
],
"webhookId": "e9177cf8-aab6-4cc0-8086-073c294dd575",
"parameters": {
"path": "items",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 2.1
},
{
"id": "4cb95925-d5be-4594-93d1-84cecaabc99d",
"name": "Webhook:读取全部",
"type": "n8n-nodes-base.webhook",
"position": [
0,
224
],
"webhookId": "e9177cf8-aab6-4cc0-8086-073c294dd575",
"parameters": {
"path": "items/all",
"options": {},
"responseMode": "responseNode"
},
"typeVersion": 2.1
},
{
"id": "a18c5a15-92bf-4897-83c7-0c0a4aaeb58a",
"name": "响应 Webhook:创建",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
448,
0
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "{\n \"status\": \"success\",\n \"message\": \"Record created.\"\n}"
},
"typeVersion": 1.4
},
{
"id": "6ee8437b-6340-4cdc-b39b-1951461d4164",
"name": "响应 Webhook:读取全部",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
448,
224
],
"parameters": {
"options": {},
"respondWith": "allIncomingItems"
},
"typeVersion": 1.4
},
{
"id": "1560785d-b30e-49b5-94f4-27445538d086",
"name": "Webhook:读取",
"type": "n8n-nodes-base.webhook",
"position": [
0,
448
],
"webhookId": "e9177cf8-aab6-4cc0-8086-073c294dd575",
"parameters": {
"path": "items",
"options": {},
"responseMode": "responseNode"
},
"typeVersion": 2.1
},
{
"id": "46baff34-99e4-4c6a-9395-76fc5358c5a7",
"name": "获取工作表中的行",
"type": "n8n-nodes-base.googleSheets",
"position": [
224,
224
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk",
"cachedResultName": "REST API data"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "FboA3kaXSneJmEGX",
"name": "Google Service Account account"
}
},
"typeVersion": 4.7
},
{
"id": "1cbcf7af-d1ba-4994-a795-d5c597439bad",
"name": "获取工作表中的单行",
"type": "n8n-nodes-base.googleSheets",
"position": [
224,
448
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "={{ $json.query.id }}",
"lookupColumn": "=row_number"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk",
"cachedResultName": "REST API data"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "FboA3kaXSneJmEGX",
"name": "Google Service Account account"
}
},
"typeVersion": 4.7
},
{
"id": "ebaf7824-73af-47c2-8e3d-a19947a91892",
"name": "响应 Webhook:读取",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
448,
448
],
"parameters": {
"options": {}
},
"typeVersion": 1.4
},
{
"id": "6cbd2531-b9f4-4a3f-b821-bec3caf2d09d",
"name": "Webhook:更新",
"type": "n8n-nodes-base.webhook",
"position": [
0,
672
],
"webhookId": "e9177cf8-aab6-4cc0-8086-073c294dd575",
"parameters": {
"path": "items",
"options": {},
"httpMethod": "PUT",
"responseMode": "responseNode"
},
"typeVersion": 2.1
},
{
"id": "b91994a3-ef36-4770-99dc-926640496693",
"name": "在表格中更新行",
"type": "n8n-nodes-base.googleSheets",
"position": [
448,
672
],
"parameters": {
"columns": {
"value": {
"name": "={{ $json.body.name }}",
"email": "={{ $json.body.email }}",
"status": "={{ $json.body.status }}",
"row_number": "={{ $json.query.id }}"
},
"schema": [
{
"id": "name",
"type": "string",
"display": true,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email",
"type": "string",
"display": true,
"required": false,
"displayName": "email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "status",
"type": "string",
"display": true,
"required": false,
"displayName": "status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "row_number",
"type": "number",
"display": true,
"removed": false,
"readOnly": true,
"required": false,
"displayName": "row_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [
"row_number"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk",
"cachedResultName": "REST API data"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "FboA3kaXSneJmEGX",
"name": "Google Service Account account"
}
},
"typeVersion": 4.7
},
{
"id": "5180a531-5efa-4fba-a870-61f7223fcb93",
"name": "响应 Webhook:更新",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
672,
672
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "{\n \"status\": \"success\",\n \"message\": \"Record updated.\"\n}"
},
"typeVersion": 1.4
},
{
"id": "ec3b5abd-17ae-4964-b792-5d320ad7a65b",
"name": "Webhook:删除",
"type": "n8n-nodes-base.webhook",
"position": [
0,
896
],
"webhookId": "e9177cf8-aab6-4cc0-8086-073c294dd575",
"parameters": {
"path": "items",
"options": {},
"httpMethod": "DELETE",
"responseMode": "responseNode"
},
"typeVersion": 2.1
},
{
"id": "b3950509-6173-4a30-bbaa-42ef34b15878",
"name": "从表格中删除行或列",
"type": "n8n-nodes-base.googleSheets",
"position": [
224,
896
],
"parameters": {
"operation": "delete",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk",
"cachedResultName": "REST API data"
},
"startIndex": "={{ $json.query.id }}",
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "FboA3kaXSneJmEGX",
"name": "Google Service Account account"
}
},
"typeVersion": 4.7
},
{
"id": "0361a349-a259-4a3c-877e-2bb7bee0f9be",
"name": "响应 Webhook:删除",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
448,
896
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "{\n \"status\": \"success\",\n \"message\": \"Record deleted.\"\n}"
},
"typeVersion": 1.4
},
{
"id": "ba367266-005d-42a0-aeba-2b48db0fea05",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-688,
0
],
"parameters": {
"width": 592,
"height": 992,
"content": "## 使用 Google Sheets 的简易 REST API"
},
"typeVersion": 1
},
{
"id": "8264647e-c5b2-4bf1-90a7-6fc0e8e5c2b9",
"name": "准备更新字段",
"type": "n8n-nodes-base.set",
"position": [
224,
672
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"row_number\": {{ $json.query.id }}\n {{ $if($json.body.keys().length > 0, ', ' + $json.body.toJsonString().replace('{', '').replace('}', ''), '') }}\n}\n"
},
"typeVersion": 3.4
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "a0da6d17-701f-4d0f-a49d-b66b5fecd7b2",
"connections": {
"Webhook: Read": {
"main": [
[
{
"node": "Get row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Webhook: Create": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Webhook: Delete": {
"main": [
[
{
"node": "Delete rows or columns from sheet",
"type": "main",
"index": 0
}
]
]
},
"Webhook: Update": {
"main": [
[
{
"node": "Prepare Fields for Update",
"type": "main",
"index": 0
}
]
]
},
"Get row in sheet": {
"main": [
[
{
"node": "Respond to Webhook: Read",
"type": "main",
"index": 0
}
]
]
},
"Get rows in sheet": {
"main": [
[
{
"node": "Respond to Webhook: Read All",
"type": "main",
"index": 0
}
]
]
},
"Webhook: Read All": {
"main": [
[
{
"node": "Get rows in sheet",
"type": "main",
"index": 0
}
]
]
},
"Append row in sheet": {
"main": [
[
{
"node": "Respond to Webhook: Create",
"type": "main",
"index": 0
}
]
]
},
"Update row in sheet": {
"main": [
[
{
"node": "Respond to Webhook: Update",
"type": "main",
"index": 0
}
]
]
},
"Prepare Fields for Update": {
"main": [
[
{
"node": "Update row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Delete rows or columns from sheet": {
"main": [
[
{
"node": "Respond to Webhook: Delete",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工程, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 Unli.dev 生成系统提示
使用 Unli.dev 为 LLM 生成 AI 系统提示
Set
Webhook
Http Request
+2
7 节点Khairul Muhtadin
工程
学习带认证和Supabase集成的安全Webhook API
学习带认证和Supabase集成的安全Webhook API
Set
Webhook
Supabase
+2
27 节点Wayne Simpson
工程
竞争对手内容差距分析器:自动化网站主题映射
使用Gemini AI、Apify和Google Sheets分析竞争对手内容差距
If
Set
Code
+10
30 节点Mychel Garzon
杂项
教练入职与培训自动化
使用短信、Twilio和Google表格自动化30天教练培训
If
Set
Code
+7
36 节点Ronnie Craig
内容创作
来自多个招聘网站的求职自动化
使用 5 个招聘平台和 AI 简历生成器自动化求职与申请
If
Set
Code
+14
34 节点Gerald Denor
个人效率
自动化潜在客户呼叫:VAPI、Google Sheets记录与日历预约
自动化潜在客户呼叫:VAPI、Google Sheets记录与日历预约
Set
Code
Webhook
+7
13 节点Meak
内容创作