电子表格中带红色标记修正的代码审查
高级
这是一个Engineering, AI Summarization领域的自动化工作流,包含 16 个节点。主要使用 Set, Slack, Function, GoogleSheets, Agent 等节点。 AI驱动代码审查,含代码检查、Google Sheets红色标记修正和Slack通知
前置要求
- •Slack Bot Token 或 Webhook URL
- •Google Sheets API 凭证
- •Google Gemini API Key
使用的节点 (16)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "CCpAUiVj1gyJZJUw",
"meta": {
"instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
"templateCredsSetupCompleted": true
},
"name": "电子表格中带红色标记修正的代码审查",
"tags": [],
"nodes": [
{
"id": "4af3c4b2-b7ad-407f-8ead-8509bde98b71",
"name": "代码输入表单监控",
"type": "n8n-nodes-base.googleSheetsTrigger",
"position": [
-624,
0
],
"parameters": {
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SHEET_GID_OR_NAME>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit#gid=0",
"cachedResultName": "対象コード"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SPREADSHEET_ID>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit?usp=drivesdk",
"cachedResultName": "コードレビュー"
}
},
"typeVersion": 1
},
{
"id": "47c973ae-f613-4a3c-ba53-0166e9a617a0",
"name": "审查结果格式化",
"type": "n8n-nodes-base.set",
"position": [
464,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "reviewedCode",
"type": "string",
"value": "={{ $json.output }}"
},
{
"id": "id-2",
"name": "originalCode",
"type": "string",
"value": "={{ $('コード入力シート監視').item.json.code }}"
},
{
"id": "id-3",
"name": "timestamp",
"type": "string",
"value": "={{ $now.toISO() }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2bab7e4b-daab-4a05-83bd-2b60465077e9",
"name": "审查结果写入",
"type": "n8n-nodes-base.googleSheets",
"position": [
608,
0
],
"parameters": {
"columns": {
"value": {},
"schema": [],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SHEET_GID_OR_NAME>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit#gid=1115979776",
"cachedResultName": "レビュー結果"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SPREADSHEET_ID>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit?usp=drivesdk",
"cachedResultName": "コードレビュー"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "WyvnXUuLPJ70Wazr",
"name": "Google Sheets account 18"
}
},
"typeVersion": 4.7
},
{
"id": "b6dda288-7b1b-41a0-9e88-f8cadc6499b6",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-176,
0
],
"parameters": {
"text": "=Lint summary (consider in review):\n{{ JSON.stringify($('Lint Check').first().json.lintErrors) }}\n\nLint score: {{ $('Lint Check').first().json.lintScore }} / 10\n\n=あなたはコードレビューの専門家です。以下のコードをレビューし、修正が必要な箇所を赤字で示してください。元のコードに対して、修正案を赤字(HTMLの<span style=\"color:red\">タグ)で追記した形式で出力してください。\n\n{{ $json.reviewPrompt }}\n\nコード:\n{{ $('コード入力シート監視').item.json.code }}\n\n【Review Rules】\n- Classify issues as Critical / Major / Minor\n- Use <span style=\"color:red\">red</span> for critical fixes; <span style=\"color:orange\">orange</span> for minor suggestions\n- Append JSON at end: {\"overall_score\": <0-10 number>}\n",
"options": {},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "05ee83db-4b56-43ee-b153-3ba224393f88",
"name": "Google Gemini 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
-176,
224
],
"parameters": {
"options": {}
},
"typeVersion": 1
},
{
"id": "a4fd65ae-4f56-4b3a-be8c-29d2a0b171f8",
"name": "在 Google Sheets 中获取行",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
-32,
224
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SHEET_GID_OR_NAME>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit#gid=2003594084",
"cachedResultName": "コード規約"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SPREADSHEET_ID>",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ABYuKFtVf1qgXa8S8yDNOKu7yCuDQzKPZQ-oufhsTJY/edit?usp=drivesdk",
"cachedResultName": "コードレビュー"
},
"authentication": "serviceAccount",
"descriptionType": "manual",
"toolDescription": "記載される内容をもとにレビュー"
},
"typeVersion": 4.7
},
{
"id": "27a24123-0992-4af0-98f4-d37148cb6b5d",
"name": "表单触发器说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-688,
-128
],
"parameters": {
"content": "监控\"代码输入\"表单中的新增或编辑行,自动启动审查流程。"
},
"typeVersion": 1
},
{
"id": "11e67e60-aaf1-49f0-a53c-93c9efde194d",
"name": "AI审查说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-448,
-128
],
"parameters": {
"content": "将提交的代码发送到连接的AI模型(如Gemini或GPT)进行详细审查和反馈。"
},
"typeVersion": 1
},
{
"id": "e81e15e9-55fa-46c4-b4d1-4304b6bb975c",
"name": "格式化说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-192,
-128
],
"parameters": {
"content": "格式化AI的审查回复——用红色文本标记修正内容,并提供清晰的改进建议。"
},
"typeVersion": 1
},
{
"id": "d2569a9f-fa2c-4979-9137-a4182b425528",
"name": "输出写入说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
176,
-128
],
"parameters": {
"width": 528,
"content": "将经过审查和修正的代码输出写入\"审查结果\"表单,便于对比查看。"
},
"typeVersion": 1
},
{
"id": "6cb8265d-a2a8-4542-80b6-358181a239ee",
"name": "代码规范检查",
"type": "n8n-nodes-base.function",
"position": [
-400,
0
],
"parameters": {
"functionCode": "const code = $('コード入力シート監視').item.json.code || '';\nconst errors = [];\nif (code.includes('var ')) errors.push({type:'Major', msg:'Avoid var; use let/const.'});\nif (code.includes('console.log')) errors.push({type:'Minor', msg:'Remove console.log in production.'});\nconst open = (code.match(/\\{/g)||[]).length;\nconst close = (code.match(/\\}/g)||[]).length;\nif (open !== close) errors.push({type:'Critical', msg:`Brace imbalance: {=${open}} }=${close}`});\nconst score = Math.max(0, 10 - errors.length * 2);\nreturn [{ json: { code, lintErrors: errors, lintScore: score }}];\n"
},
"typeVersion": 1
},
{
"id": "8850c4ee-5296-4a3c-aaca-d6bd9d4bdde2",
"name": "格式化审查输出",
"type": "n8n-nodes-base.function",
"position": [
176,
0
],
"parameters": {
"functionCode": "const out = $json.output || '';\nconst lint = $('Lint Check').first().json || {};\nconst errors = lint.lintErrors || [];\nconst counts = { Critical:0, Major:0, Minor:0 };\nerrors.forEach(e=>{ if (counts[e.type]!==undefined) counts[e.type]++; });\nlet overall = Number((lint.lintScore || 0));\nconst m = out.match(/\\{\\\"overall_score\\\"\\s*:\\s*([0-9.]+)\\}/);\nif (m) overall = (overall + Number(m[1]))/2;\nreturn [{ json: { reviewed: out, lintSummary: counts, lintScore: lint.lintScore||0, overallScore: Number(overall.toFixed(2)) } }];\n"
},
"typeVersion": 1
},
{
"id": "a04d8968-8941-440f-bce7-21f42eca1771",
"name": "汇总审查统计",
"type": "n8n-nodes-base.function",
"position": [
320,
0
],
"parameters": {
"functionCode": "const s = $json.lintSummary || {Critical:0, Major:0, Minor:0};\nconst overall = $json.overallScore || 0;\nreturn [{ json: { summary: s, overall, summaryText: `Critical:${s.Critical} Major:${s.Major} Minor:${s.Minor} / Score:${overall}` } }];\n"
},
"typeVersion": 1
},
{
"id": "80ece42d-3536-4880-9a12-b745204e40b0",
"name": "发布审查摘要",
"type": "n8n-nodes-base.slack",
"position": [
832,
0
],
"webhookId": "43a4cf92-a74a-4e30-b59a-f0bcae7bef4a",
"parameters": {
"text": "={{ `✅ Code Review Completed\\n${$json.summaryText}` }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "<YOUR_SLACK_CHANNEL_ID>",
"cachedResultName": "code-reviews"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"typeVersion": 2.3
},
{
"id": "9eb4292c-e03e-4e00-bbf5-8d6b19fb78e2",
"name": "模板概览(高级版)",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1264,
-368
],
"parameters": {
"width": 520,
"height": 1120,
"content": "## 高级代码审查自动化(AI + 代码规范检查 + Slack)"
},
"typeVersion": 1
},
{
"id": "3198d5f4-06c1-43a4-8e88-a76c9c67eff9",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
176
],
"parameters": {
"content": "添加编码规范和设计文档作为工具。"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "64769cf0-2122-4615-a487-6ea7fc3dc2b1",
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Format Review Output",
"type": "main",
"index": 0
}
]
]
},
"Lint Check": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Format Review Output": {
"main": [
[
{
"node": "Aggregate Review Stats",
"type": "main",
"index": 0
}
]
]
},
"Aggregate Review Stats": {
"main": [
[
{
"node": "レビュー結果整形",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"レビュー結果整形": {
"main": [
[
{
"node": "レビュー結果書き込み",
"type": "main",
"index": 0
}
]
]
},
"コード入力シート監視": {
"main": [
[
{
"node": "Lint Check",
"type": "main",
"index": 0
}
]
]
},
"レビュー結果書き込み": {
"main": [
[
{
"node": "Post Review Summary",
"type": "main",
"index": 0
}
]
]
},
"Get row(s) in sheet in Google Sheets": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工程, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
带 AI 过滤的个性化学习内容聚合器
使用 GPT-4.1-mini 和 Google Sheets 从 Reddit 和 RSS 筛选学习内容
Set
Code
Merge
+7
18 节点higashiyama
市场调研
RSS源智能中心与每日Slack摘要
使用Gemini AI为RSS源自动化新闻智能,推送至Notion和Slack
Set
Code
Sort
+9
29 节点Takuya Ojima
市场调研
电子邮件扫描和Google表格采购订单创建
使用Gemini AI从Gmail提取采购订单并保存至Google表格
If
Set
Code
+8
15 节点Sayone Technologies
文档提取
基础提示词转换为专业 AI 提示词(多智能体优化)
通过多智能体优化将基础提示词转换为专业 AI 提示词
Set
Code
Switch
+9
19 节点EoCi - Mr.Eo
工程
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
音乐生成工作流
使用 Suno API、Flux、Runway 和 Creatomate 生成 AI 歌曲和音乐视频
Set
Wait
Merge
+16
60 节点Joseph
其他