Skip to content

Root#

$()#

Description: 返回指定节点的数据

Syntax: $(nodeName)

Returns: NodeData

Source: Custom n8n functionality

Parameters:

  • nodeName (String) - 要获取数据的节点名称

$binary#

Description: 返回当前节点当前数据项的所有二进制输入数据。是 $input.item.binary 的简写形式。

Syntax: $binary

Returns: Array

Source: Custom n8n functionality

$execution#

Description: 获取或设置当前执行的元数据

Syntax: $execution

Returns: ExecData

Source: Custom n8n functionality

$fromAI()#

Description: 当大语言模型需要提供节点参数的值时使用。建议提供描述以获得更好的结果。

Syntax: $fromAI(key, description?, type?, defaultValue?)

Returns: any

Source: Custom n8n functionality

Parameters:

  • key (String) - 要获取的字段名称。只能包含字母、数字、下划线和连字符。
  • description (String) - 可选 - 用于给模型提供更多上下文,说明应该返回什么内容
  • type (String) - 可选 - 要返回的值的类型。可选值:stringnumberbooleanjsondatedatetime。默认为 string
  • defaultValue (any) - 可选 - 当模型未返回该键时使用的默认值

Examples:

1
2
// Ask the model to provide a name, and use it here
$fromAI('name')
1
2
// Ask the model to provide the age of the person (as a number with a default value of 18), and use it here
$fromAI('age', 'The age of the person', 'number', 18)
1
2
// Ask the model to provide a boolean signifying whether the person is a student (with default value false), and use it here
$fromAI('isStudent', 'Is the person a student', 'boolean', false)

$if()#

Description: 根据 condition 返回两个值中的一个。类似于 JavaScript 中的 ? 运算符。

Syntax: $if(condition, valueIfTrue, valueIfFalse)

Returns: any

Source: Custom n8n functionality

Parameters:

  • condition (Boolean) - 要进行的检查。应该求值为 truefalse
  • valueIfTrue (any) - 条件为 true 时返回的值
  • valueIfFalse (any) - 条件为 false 时返回的值

Examples:

1
2
// Return "Good day" if time is before 5pm, otherwise "Good evening"
$if($now.hour < 17, "Good day", "Good evening")
1
2
3
// $if() calls can be combined:
// Return "Good morning" if time is before 10am, "Good day" it's before 5pm, otherwise "Good evening"
$if($now.hour < 10, "Good morning", $if($now.hour < 17, "Good day", "Good evening"))

$ifEmpty()#

Description: 如果第一个参数不为空则返回它,否则返回第二个参数。以下值被视为空:""[]{}nullundefined

Syntax: $ifEmpty(value, valueIfEmpty)

Returns: any

Source: Custom n8n functionality

Parameters:

  • value (any) - 要返回的值(前提是它不为空)
  • valueIfEmpty (any) - 当 value 为空时返回的值

Examples:

1
"Hi " + $ifEmpty(name, "there") // e.g. "Hi Nathan" or "Hi there"

$input#

Description: 当前节点的输入数据

Syntax: $input

Returns: NodeData

Source: Custom n8n functionality

$itemIndex#

Description: 当前正在处理的数据项在输入数据项列表中的位置

Syntax: $itemIndex

Returns: Number

Source: Custom n8n functionality

$jmespath()#

Description: 使用 JMESPath 表达式从对象(或对象数组)中提取数据。对于查询复杂的嵌套对象非常有用。如果表达式无效则返回 undefined

Syntax: $jmespath(obj, expression)

Returns: any

Source: Custom n8n functionality

Parameters:

  • obj (Object|Array) - 要从中提取数据的 Object 或 Object 数组
  • expression (String) - 定义要从对象中提取的数据的 JMESPath 表达式

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
data = {
  "people": [
    {
      "age": 20,
      "other": "foo",
      "name": "Bob"
    },
    {
      "age": 25,
      "other": "bar",
      "name": "Fred"
    },
    {
      "age": 30,
      "other": "baz",
      "name": "George"
    }
  ]
}

// Get all names, in an array
{{ $jmespath(data, '[*].name') }} //=> ["Bob", "Fred", "George"]

// Get the names and ages of everyone under 20
$jmespath(data, '[?age > `20`].[name, age]') //=> [ ["Fred",25], ["George",30] ]

// Get the name of the first person under 20
$jmespath($json.people, '[?age > `20`].name | [0]') //=> Fred
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
data = {
    "reservations": [
      {
        "id": 1,
        "guests": [
          {
            "name": "Nathan",
            "requirements": {
              "room": "double",
              "meal": "vegetarian"
            }
          },
          {
            "name": "Meg",
            "requirements": {
              "room": "single"
            }
          }
        ]
      },
      {
        "id": 2,
        "guests": [
          {
            "name": "Lex",
            "requirements": {
              "room": "double"
            }
          }
        ]
      }
    ]
  }

// Get the names of all the guests in each reservation that require a double room
$jmespath(data, 'reservations[].guests[?requirements.room==`double`].name')

$json#

Description: 返回当前节点当前数据项的 JSON 输入数据。是 $input.item.json 的简写形式。更多信息

Syntax: $json

Returns: Object

Source: Custom n8n functionality

$max()#

Description: 返回给定数字中的最大值

Syntax: $max(num1, num2, …, numN)

Returns: Number

Source: Custom n8n functionality

Parameters:

  • num1 (Number) - 要比较的第一个数字
  • num2 (Number) - 要比较的第二个数字

$min()#

Description: 返回给定数字中的最小值

Syntax: $min(num1, num2, …, numN)

Returns: Number

Source: Custom n8n functionality

Parameters:

  • num1 (Number) - 要比较的第一个数字
  • num2 (Number) - 要比较的第二个数字

$nodeVersion#

Description: 当前节点的版本号(显示在节点设置面板底部)

Syntax: $nodeVersion

Returns: String

Source: Custom n8n functionality

$now#

Description: 表示当前时刻的 DateTime。

使用工作流的时区(可以在工作流设置中更改)。

Syntax: $now

Returns: DateTime

Source: Custom n8n functionality

$pageCount#

Description: 节点已获取的结果页数。仅在 'HTTP Request' 节点中可用。

Syntax: $pageCount

Returns: Number

Source: Custom n8n functionality

$parameter#

Description: 当前节点的配置设置。这些是你在节点 UI 中填写的参数(例如其操作类型)。

Syntax: $parameter

Returns: NodeParams

Source: Custom n8n functionality

$prevNode#

Description: 关于当前输入来源节点的信息。

在 'Merge' 节点中时,始终使用第一个输入连接器。

Syntax: $prevNode

Returns: PrevNodeData

Source: Custom n8n functionality

$request#

Description: 节点最近一次运行时发送的请求对象。仅在 'HTTP Request' 节点中可用。

Syntax: $request

Returns: Object

Source: Custom n8n functionality

$response#

Description: 最近一次 HTTP 调用返回的响应。仅在 'HTTP Request' 节点中可用。

Syntax: $response

Returns: HTTPResponse

Source: Custom n8n functionality

$runIndex#

Description: 当前节点执行的当前运行索引。从 0 开始。

Syntax: $runIndex

Returns: Number

Source: Custom n8n functionality

$secrets#

Description: 来自外部密钥保管库的密钥(如果已配置)。密钥值永远不会向用户显示。仅在凭据字段中可用。

Syntax: $secrets

Returns: Object

Source: Custom n8n functionality

$today#

Description: 表示当天午夜零点的 DateTime。

使用实例的时区(除非在工作流设置中被覆盖)。

Syntax: $today

Returns: DateTime

Source: Custom n8n functionality

$vars#

Description: 工作流可用的变量

Syntax: $vars

Returns: Object

Source: Custom n8n functionality

$workflow#

Description: 关于当前工作流的信息

Syntax: $workflow

Returns: WorkflowData

Source: Custom n8n functionality