该技能包用于在编写自定义 n8n 节点时提供语法与类型参考,主要服务于节点定义、属性声明、执行方法实现和声明式节点构建等开发环节。
用途:在创建自定义 n8n 节点、定义节点属性、实现 execute 方法或构建声明式节点时使用,帮助避免 INodeProperties 等配置错误。
主要内容:
- INodeType 接口成员:列出 description、execute、trigger、poll、webhook、supplyData、methods、webhookMethods 等成员的签名、是否必填及用途。
- INodeTypeDescription 关键字段:包括 displayName、name、icon、group、version、description、defaults、inputs、outputs、credentials、properties、polling、webhooks、requestDefaults、usableAsTool、subtitle 等字段的类型、必填性和说明。
- 属性类型:列出 22 种 NodePropertyTypes,包含 boolean、button、collection、color、dateTime、fixedCollection、hidden、icon、json、callout、notice、multiOptions、number、options、string、credentialsSelect、resourceLocator、curlImport、resourceMapper、filter、assignmentCollection、workflowSelector、credentials,并给出对应 UI 元素和默认值类型。
- IExecuteFunctions 常用方法:getInputData、getNodeParameter、getCredentials、continueOnFail、executeWorkflow、putExecutionToWait、sendMessageToUI,以及 helpers.httpRequest、helpers.getBinaryDataBuffer、helpers.prepareBinaryData、helpers.normalizeItems。
- 关键注意事项:execute 必须返回 INodeExecutionData[][];按输入项索引循环并读取参数;在 catch 中处理 continueOnFail;参数值使用 IDataObject 普通对象;声明式节点不写 execute;触发节点 inputs 为空数组;Node 基类使用 context 参数而非 this;资源与操作选择器属性设置 noDataExpression: true。
- 决策树:根据是否为触发节点、是否响应 HTTP 请求、是否轮询外部服务等选择 Webhook、Poll、Trigger、声明式或程序化模式;根据用户提供的数据形态选择合适属性类型。
- 示例模式:程序化节点(实现 INodeType)、Node 基类(context 参数)、声明式节点(routing 配置)、displayOptions 条件显示(含 @version 与 _cnd 运算符)、版本化节点(IVersionedNodeType)、methods 对象(loadOptions、listSearch、credentialTest、resourceMapping)。
- INodeExecutionData 结构:json 为必填字段,binary、error、pairedItem 为可选;execute 返回二维数组,外层对应输出连接器,内层为该输出的数据项。
使用方式:资料以参考文档与代码示例形式提供,开发者按需查阅接口签名、字段表和示例代码,并在项目 references 目录下参考 methods.md、examples.md、anti-patterns.md 等文件。
适用场景:n8n 自定义节点开发、节点属性定义、触发与轮询节点实现、声明式 REST API 节点构建、节点版本升级与动态选项加载。
限制:资料聚焦节点语法与类型定义,未提供具体安装命令、收费信息或运行环境要求;部分内容需结合 n8n 官方文档与源码进一步确认。