Skip to content

根(Root)#

$()#

描述: 返回指定节点的数据

语法: $(nodeName)

返回: 节点数据

来源: 自定义 n8n 功能

参数:

  • nodeName(字符串)- 要检索数据的节点名称

$binary#

描述: 将任何二进制输入数据返回到当前节点的当前项目。$input.item.binary 的简写。

语法: $binary

返回: 数组

来源: 自定义 n8n 功能

$execution#

描述: 检索或设置当前执行的元数据

语法: $execution

返回值: ExecData

来源: 自定义 n8n 功能

$fromAI()#

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

语法: $fromAI(key, 描述?, 类型?, 默认值?)

返回值: 任意

来源: 自定义 n8n 功能

参数:

  • key(字符串)- 要获取的字段名。只能包含字母、数字、下划线和连字符。
  • description(字符串)- 可选 - 用于向模型提供更多关于它应该返回内容的具体上下文
  • type(字符串)- 可选 - 要返回的值的类型。可以是 stringnumberbooleanjsondatedatetime 中的一种。默认值为 string
  • defaultValue(any)- 可选 - 如果模型未返回该键时使用的值

示例:

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()#

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

语法: $if(条件, 条件为真时的值, 条件为假时的值)

返回值: 任意

来源: 自定义 n8n 功能

参数:

  • condition(布尔值)- 要进行的检查。应评估为 truefalse
  • valueIfTrue(any)- 如果条件为真要返回的值
  • valueIfFalse(any)- 如果条件为假时要返回的值

示例:

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()#

描述: 如果第一个参数不为空,则返回第一个参数,否则返回第二个参数。以下情况视为空:””[]{}nullundefined

语法: $ifEmpty(value, valueIfEmpty)

返回值: 任意

来源: 自定义 n8n 功能

参数:

  • value(any)- 要返回的值,前提是它不是空的
  • valueIfEmpty(any)- 如果 value 为空,返回什么

示例:

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

$input#

描述: 当前节点的输入数据

语法: $input

返回: 节点数据

来源: 自定义 n8n 功能

$itemIndex#

描述: 当前正在处理的项目在输入项目列表中的位置

语法: $itemIndex

返回值: 数字

来源: 自定义 n8n 功能

$jmespath()#

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

语法: $jmespath(obj, expression)

返回值: 任意

来源: 自定义 n8n 功能

参数:

  • obj(对象|数组)- 要从中检索数据的对象或对象数组
  • expression(字符串)- A JMESPath 表达式 定义要从对象中检索的数据

示例:

 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#

描述: 返回当前节点的 JSON 输入数据,针对当前条目。$input.item.json 的简写。 更多信息

语法: $json

返回值:对象

来源: 自定义 n8n 功能

$max()#

描述: 返回给定数字中最大的数

语法: $max(num1, num2, …, numN)

返回值: 数字

来源: 自定义 n8n 功能

参数:

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

$min()#

描述: 返回给定数字中最小的一个

语法: $min(num1, num2, …, numN)

返回值: 数字

来源: 自定义 n8n 功能

参数:

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

$nodeVersion#

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

语法: $nodeVersion

返回值: 字符串

来源: 自定义 n8n 功能

$now#

描述: 表示当前时刻的日期时间。

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

🌐 Uses the workflow’s time zone (which can be changed in the workflow settings).

语法: $now

返回值: 日期时间

来源: 自定义 n8n 功能

$pageCount#

描述: 节点已获取的结果页面数量。仅在“HTTP 请求”节点中可用。

语法: $pageCount

返回值: 数字

来源: 自定义 n8n 功能

$parameter#

描述: 当前节点的配置设置。这些是你在节点的用户界面中填写的参数(例如,它的操作)。

语法: $parameter

返回值: NodeParams

来源: 自定义 n8n 功能

$prevNode#

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

在“合并”节点中,总是使用第一个输入连接器。

🌐 When in a ‘Merge’ node, always uses the first input connector.

语法: $prevNode

返回: PrevNodeData

来源: 自定义 n8n 功能

$request#

描述: 在节点的上一次运行期间发送的请求对象。仅在“HTTP 请求”节点中可用。

语法: $request

返回值:对象

来源: 自定义 n8n 功能

$response#

描述: 最后一次 HTTP 调用返回的响应。仅在“HTTP 请求”节点中可用。

语法: $response

返回: HTTP响应

来源: 自定义 n8n 功能

$runIndex#

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

语法: $runIndex

返回值: 数字

来源: 自定义 n8n 功能

$secrets#

描述: 来自 外部秘密库的秘密(如果已配置)。秘密值从不向用户显示。仅在凭证字段中可用。

语法: $secrets

返回值:对象

来源: 自定义 n8n 功能

$today#

描述: 表示当前日期开始时午夜的日期时间。

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

🌐 Uses the instance’s time zone (unless overridden in the workflow’s settings).

语法: $today

返回值: 日期时间

来源: 自定义 n8n 功能

$vars#

描述: 工作流可用的 变量

语法: $vars

返回值:对象

来源: 自定义 n8n 功能

$workflow#

描述: 当前工作流程的信息

语法: $workflow

返回: 工作流数据

来源: 自定义 n8n 功能