模板_代码_智能感知
中级
这是一个Engineering领域的自动化工作流,包含 8 个节点。主要使用 N8n, Code, Form, FormTrigger 等节点。 使用JSDoc为代码节点添加TypeScript智能感知支持
前置要求
- •无特殊前置要求,导入即可使用
使用的节点 (8)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "CHfMFle2Ym5WrORl",
"meta": {
"instanceId": "87021cc08fe86f3c88c615ac7015b93e398b6bf953b85302471896e86cc798ef",
"templateCredsSetupCompleted": true
},
"name": "模板_代码_智能感知",
"tags": [],
"nodes": [
{
"id": "4bb15488-9fbd-4233-a5fd-4ea336a28a04",
"name": "获取此工作流",
"type": "n8n-nodes-base.n8n",
"position": [
-300,
-20
],
"parameters": {
"operation": "get",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"requestOptions": {}
},
"credentials": {
"n8nApi": {
"id": "AtnwjrQQjpB80Z2Q",
"name": "n8n unio API v1"
}
},
"typeVersion": 1
},
{
"id": "9e494c46-e9fc-40db-8a79-1329c46f30dc",
"name": "带智能感知的代码",
"type": "n8n-nodes-base.code",
"position": [
-20,
-20
],
"parameters": {
"jsCode": "// ----------------------------------------------------------------\n\n// Define core classes you want intellisense for.\n\n/**\n * @typedef {Object} Node\n * @property {string} type\n * @property {number} typeVersion\n * @property {number} id\n * @property {string} name\n */\n\n/**\n * @typedef {Object} Workflow\n * @property {string} name\n * @property {number} id\n * @property {boolean} isArchived\n * @property {Array<Node>} nodes\n */\n\n// Use this inline casting to tell Intellisense what the variable is:\nconst wf = /** @type {Workflow} */ ($input.first().json);\n\nlet output = \"<p>Example:</p>\"; \n\n// Now check and see, wf will present Intellisense!\noutput += \"<p>Workflow.id: \" + wf.id + \"</p>\";\noutput += \"<p>Workflow.name: \" + wf.name + \"</p>\";\noutput += \"<p>Workflow.isArchived: \" + wf.isArchived + \"</p>\";\n\nfor (let i = 0; i < wf.nodes.length; i++) {\n const node = wf.nodes[i];\n // node will automatically know its type, Intellisense here\n output += \"<p>Workflow.nodes[\" + i + \"]: \" + node.name + \"</p>\";\n output += \"<p>Workflow.nodes[\" + i + \"]: \" + node.type + \"</p>\";\n}\n\nreturn [{ json: { result: output } }];"
},
"typeVersion": 2
},
{
"id": "6aeaf1f3-0eca-4f27-8a8e-62cae8e860c7",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-580,
-140
],
"parameters": {
"color": 7,
"width": 480,
"height": 320,
"content": "## 设置"
},
"typeVersion": 1
},
{
"id": "7fe8b7e9-0571-433f-b04a-4f2af8b69aa9",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-140
],
"parameters": {
"color": 4,
"width": 480,
"height": 320,
"content": "## 示例"
},
"typeVersion": 1
},
{
"id": "74a61d70-17eb-44a5-a23c-c7f3035295e5",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
-520,
-20
],
"webhookId": "d963f33b-cba8-4887-b9d1-65fe4bbc49ad",
"parameters": {
"options": {},
"formTitle": "Test Code Node"
},
"typeVersion": 2.2
},
{
"id": "758fcb50-9794-45c9-a9b1-c490fdd96fd8",
"name": "显示结果",
"type": "n8n-nodes-base.form",
"position": [
480,
-20
],
"webhookId": "a45895a4-717c-4542-8663-8d6352ba8d19",
"parameters": {
"options": {},
"formFields": {
"values": [
{
"html": "{{ $json.result }}\n\n",
"fieldType": "html",
"elementName": "output"
}
]
}
},
"typeVersion": 1
},
{
"id": "c938cf31-ea77-496a-8e73-a960ca41a586",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
420,
-140
],
"parameters": {
"color": 7,
"width": 480,
"height": 320,
"content": "## 输出"
},
"typeVersion": 1
},
{
"id": "490fa90f-ca28-4046-a5b4-59db517c0c2d",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-580,
-280
],
"parameters": {
"color": 7,
"width": 1480,
"height": 120,
"content": "## 带智能感知的 Code 节点!"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "5c08e162-982f-4332-83a1-bca1c87af241",
"connections": {
"Display Results": {
"main": [
[]
]
},
"Get This Workflow": {
"main": [
[
{
"node": "Code With Intellisense",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Get This Workflow",
"type": "main",
"index": 0
}
]
]
},
"Code With Intellisense": {
"main": [
[
{
"node": "Display Results",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工程
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
学习n8n第1课
交互式工作流教程:学习数据流、执行模式与调试基础
Set
Code
Form
+7
73 节点Wyeth
杂项
发送并检查TTS语音通话及邮件验证
使用ClickSend和SMTP的多因素认证(语音通话和邮件)
If
Set
Code
+5
19 节点Davide
工程
INST安装程序
打包部署多个n8n工作流 - 含自动凭证映射
If
N8n
Set
+12
31 节点Wyeth
开发运维
实时Notion Todoist双向同步模板
使用Redis的Notion Todoist实时双向同步
If
Set
Code
+26
246 节点Mario
销售
将n8n标签转换为文件夹并移动工作流
将n8n标签转换为文件夹并移动工作流
If
N8n
Set
+10
40 节点Imperol
构建模块
n8n调试
使用Slack交互式消息创建调试断点和日志
If
Slack
Debug Helper
+4
9 节点Wyeth
工程