Skip to content

标准参数(Standard parameters)#

这些是node基础文件的标准参数。它们对所有节点类型都是相同的。

🌐 These are the standard parameters for the node base file. They're the same for all node types.

displayName#

字符串 | 必填

🌐 String | Required

这是用户在 n8n 图形用户界面中看到的名称。

🌐 This is the name users see in the n8n GUI.

name#

字符串 | 必填

🌐 String | Required

对象的内部名称。用于从节点的其他位置引用它。

🌐 The internal name of the object. Used to reference it from other places in the node.

icon#

字符串对象 | 必填

🌐 String or Object | Required

为特定节点指定图标。n8n 建议上传你自己的图片文件。

🌐 Specifies an icon for a particular node. n8n recommends uploading your own image file.

你可以将图标文件名作为字符串提供,或者作为对象来处理浅色和深色模式下的不同图标。 如果图标在浅色和深色模式下都可用,请使用以 file: 开头的字符串,表示图标文件的路径。例如:

🌐 You can provide the icon file name as a string, or as an object to handle different icons for light and dark modes. If the icon works in both light and dark modes, use a string that starts with file:, indicating the path to the icon file. For example:

1
icon: 'file:exampleNodeIcon.svg'
To provide different icons for light and dark modes, use an object with light and dark properties. For example:

1
2
3
4
icon: { 
  light: 'file:exampleNodeIcon.svg', 
  dark: 'file:exampleNodeIcon.dark.svg' 
}

n8n recommends using an SVG for your node icon, but you can also use PNG. If using PNG, the icon resolution should be 60x60px. Node icons should have a square or near-square aspect ratio.

Don't reference Font Awesome

If you want to use a Font Awesome icon in your node, download and embed the image.

group#

字符串数组 | 必填

🌐 Array of strings | Required

告诉 n8n 当工作流运行时节点的行为方式。选项包括:

🌐 Tells n8n how the node behaves when the workflow runs. Options are:

  • trigger:节点等待触发。
  • schedule:节点等待定时器到期。
  • inputoutputtransform:目前没有任何效果。
  • 一个空数组,[]。如果你不需要 triggerschedule,可以将其用作默认选项。

description#

字符串 | 必填

🌐 String | Required

节点的简短描述。n8n 在图形界面中使用它。

🌐 A short description of the node. n8n uses this in the GUI.

defaults#

对象 | 必填

🌐 Object | Required

包含必要的品牌和名称设置。

🌐 Contains essential brand and name settings.

对象可以包含:

🌐 The object can include:

  • name:字符串。如果 displayName 太长,将用作画布上的节点名称。
  • color:字符串。十六进制颜色代码。提供集成的品牌颜色以在 n8n 中使用。

forceInputNodeExecution#

布尔 | 可选

🌐 Boolean | Optional

在构建多输入节点时,你可以选择强制所有分支上的所有前置节点在该节点运行前执行。默认值是 false(只要求一个输入分支运行)。

🌐 When building a multi-input node, you can choose to force all preceding nodes on all branches to execute before the node runs. The default is false (requiring only one input branch to run).

inputs#

字符串数组 | 必填

🌐 Array of strings | Required

命名输入连接器。控制节点在输入端的连接器数量。如果只需要一个连接器,请使用 input: ['main']

🌐 Names the input connectors. Controls the number of connectors the node has on the input side. If you need only one connector, use input: ['main'].

outputs#

字符串数组 | 必填

🌐 Array of strings | Required

命名输出连接器。控制节点在输出端的连接器数量。如果只需要一个连接器,请使用 output: ['main']

🌐 Names the output connectors. Controls the number of connectors the node has on the output side. If you need only one connector, use output: ['main'].

requiredInputs#

整数数组 | 可选

🌐 Integer or Array | Optional

用于多输入节点。通过编号指定必须有数据的输入(它们的分支必须运行)才能执行节点。

🌐 Used for multi-input nodes. Specify inputs by number that must have data (their branches must run) before the node can execute.

credentials#

对象数组 | 必填

🌐 Array of objects | Required

此参数告诉 n8n 凭证选项。每个对象定义一种身份验证类型。

🌐 This parameter tells n8n the credential options. Each object defines an authentication type.

对象必须包含:

🌐 The object must include:

  • name:凭证名称。必须与凭证文件中的 name 属性相匹配。例如,Asana.node.ts 中的 name: 'asanaApi' 对应 AsanaApi.credential.ts 中的 name = 'asanaApi'
  • required:布尔值。指定是否需要身份验证才能使用此节点。

requestDefaults#

对象 | 必填

🌐 Object | Required

设置节点发出的 API 调用的基本信息。

🌐 Set up the basic information for the API calls the node makes.

此对象必须包含:

🌐 This object must include:

  • baseURL:API 基础 URL。

你还可以添加:

🌐 You can also add:

  • headers:描述 API 调用头的对象,例如内容类型。
  • url:字符串。附加到 baseURL。通常可以不填。更常见的是在 operations 中提供这一项。

properties#

对象数组 | 必填

🌐 Array of objects | Required

此选项包含定义节点行为的资源对象和操作对象,以及用于设置可接收用户输入的必填字段和可选字段的对象。

🌐 This contains the resource and operations objects that define node behaviors, as well as objects to set up mandatory and optional fields that can receive user input.

资源对象(Resource objects)#

资源对象包含以下参数:

🌐 A resource object includes the following parameters:

  • displayName:字符串。此处应始终为 Resource
  • name:字符串。此处应始终为 resource
  • type:字符串。告诉 n8n 使用哪个 UI 元素,以及预期的输入类型。例如,options 会导致 n8n 添加一个下拉菜单,允许用户选择一个选项。有关更多信息,请参阅 节点 UI 元素
  • noDataExpression:布尔值。阻止对该参数使用表达式。对于 resource,必须始终为 true

操作对象(Operations objects)#

操作对象定义了资源的可用操作。

🌐 The operations object defines the available operations on a resource.

  • displayName:字符串。此处应始终为 Options
  • name:字符串。此处应始终为 option
  • type:字符串。告诉 n8n 使用哪个 UI 元素,以及期望的输入类型。例如,dateTime 会导致 n8n 添加一个日期选择器。更多信息请参阅 节点 UI 元素
  • noDataExpression:布尔值。阻止对该参数使用表达式。对于 operation,必须始终为 true
  • options:对象数组。每个对象描述了一个操作的行为,例如它的路由、使用的 REST 动词等。一个 options 对象包括:
    • name。字符串。
    • value。字符串。
    • action:字符串。此参数结合了资源和操作。您应始终包含它,因为 n8n 在未来版本中会使用它。例如,假设有一个名为 "Card" 的资源和一个操作 "Get all",那么您的操作就是 "Get all cards"
    • description:字符串。
    • routing:包含请求详细信息的对象。

附加字段对象(Additional fields objects)#

这些对象定义了可选参数。n8n 会在图形界面的 其他字段 下显示它们。用户可以选择要设置哪些参数。

🌐 These objects define optional parameters. n8n displays them under Additional Fields in the GUI. Users can choose which parameters to set.

对象必须包含:

🌐 The objects must include:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
displayName: 'Additional Fields',
name: 'additionalFields',
// The UI element type
type: ''
placeholder: 'Add Field',
default: {},
displayOptions: {
  // Set which resources and operations this field is available for
  show: {
    resource: [
      // Resource names
    ],
    operation: [
      // Operation names
    ]
  },
}

有关 UI 元素类型的更多信息,请参阅 UI 元素

🌐 For more information about UI element types, refer to UI elements.