本页内容
Sommatic 文档
打开控制台

Node Reference

本次运行中任何已执行节点的输出、上一个节点,以及串联工作流的入口点。

以 Markdown 查看
在以下应用中打开

每个示例都在已部署的表达式引擎上、基于页面末尾的示例上下文运行过。

$('Node label')

$(label)

$ 是一个函数。它接收节点的标签(画布上显示的名称),返回一个访问器,指向该节点在本次运行中产生的输出。没有标签的节点按其 node_id 查找。只有已执行的节点才有输出;对于其他名称,访问器依然存在并返回空条目,因此读取结果为 undefined,而不会报错。

查找按文本进行:重命名节点会使所有读取它的表达式失效;两个节点标签相同时,以工作流中位置靠后的那个为准。请为节点设置简短、稳定且唯一的标签。

参数

label string 必填
节点的标签,须与原文完全一致(区分大小写和空格)。节点没有标签时,传入其 node_id。

返回

NodeAccessor 包含以下成员的对象。

成员

签名 类型 说明
$('X').item { json } 以条目形式表示的节点输出:item.json 即节点的返回内容。节点未执行时为 { json: {} }。
$('X').first() { json } 与 .item 相同。
$('X').last() { json } 与 .item 相同(一个节点只产生一个条目)。
$('X').all() list 包含该节点条目的列表;节点未执行时为空列表。
$('X').params 保留 object 保留:不暴露该节点的配置;始终为 {}。
$('X').context 保留 object 保留:始终为 {}。
$('X').isExecuted boolean 节点已在本次运行中执行时为 true。

示例

{{ $('Normalize input').item.json.correlation_id }}
结果 string
"c-7f3a"

在图中任意下游节点读取 webhook 的请求体。

{{ $('Webhook Receiver').item.json.body.email }}
结果 string
"ana.perez@example.com"
{{ $('Classify').item.json.confidence >= 0.8 }}
结果 boolean
true

位于另一分支或尚未到达的节点。

{{ $('Approval').isExecuted }}
结果 boolean
false

读取未执行的节点得到 undefined,而不是报错。

{{ $('Approval').item.json.decision }}
结果 undefined
undefined
{{ $('Classify').all().length }}
结果 number
1

说明

  • 节点的输出就是它通过端口返回的内容(信封中的 data),而非信封本身:$('X').item.json.ok 并不存在。
  • 位于未执行分支上的节点不算错误。需要区分时请检查 .isExecuted,例如在 flow.if 之后。

在 JSONata 中 不可用:在 JSONata 中,$ 和 $$ 表示上下文。请改用 JavaScript 表达式读取该节点。

$prevNode

保留. 引擎不会传递上一个节点:目前始终为 { name: 'Start', runIndex: 0, outputIndex: 0 }。

$prevNode

用于描述路由到当前节点的那个节点。引擎不会传递它,因此它始终保存相同的固定值。要知道是哪个节点产生了输入,请用 $('label') 读取其输出并检查 .isExecuted。

成员

签名 类型 说明
$prevNode.name 保留 string 用于表示上一个节点的名称。目前始终为 'Start'。
$prevNode.runIndex 保留 number 用于表示上一个节点的尝试序号。目前始终为 0。
$prevNode.outputIndex 保留 number 用于表示它所使用的输出端口。目前始终为 0。

示例

{{ $prevNode }}
结果 object
{"name":"Start","runIndex":0,"outputIndex":0}

在 JSONata 中 $$prevNode.name

Chain entry point

$('Chain Entry Point').item.json

通过 workflow.chain 被另一个工作流调用的工作流,从 workflow.trigger 节点开始(此处命名为 Chain Entry Point;请换成节点实际的标签)。它的输出是调用方发送的 data(展开到顶层),外加标识调用方的 chain_context。紧跟在触发器之后的节点以 $json 读取它;之后的任何节点用 $('Chain Entry Point') 读取。

在串联的工作流中,$execution.id 是链的根运行的 id,因此消息和任务在所有工作流中显示相同的引用;$execution.run_flow_instance_result_id 是这一跳的 id。

成员

签名 类型 说明
$('Chain Entry Point').item.json.<field> any 调用方发送的 data 对象中的每个字段,位于顶层。
…chain_context.caller_flow_definition_id string | null 调用方工作流的定义 id。触发器的 accepted_caller_ids 会据此校验。
…chain_context.caller_flow_instance_id string | null 调用方运行的流程实例 id。
…chain_context.caller_flow_slug string | null 调用方工作流的 slug。
…chain_context.caller_node_id string | null 发起调用的 workflow.chain 节点的 node_id。
…chain_context.correlation_id string 本次调用的 id(chain- + 20 个字符),每次调用都会重新生成。
…chain_context.root_flow_instance_result_id string | null 链的根运行的结果 id,在每一跳中都相同(它也是 $execution.id)。

示例

紧跟触发器之后:调用方发送的数据,位于顶层。

{{ $json.order_id }}
结果 string
"ord_1042"
{{ $('Chain Entry Point').item.json.chain_context.caller_flow_slug }}
结果 string
"order-intake"

编辑器会提示 data,但触发器会把调用方的字段展开到顶层:读取 .data 得到 undefined。

{{ $('Chain Entry Point').item.json.data }}
结果 undefined
undefined
{{ $('Chain Entry Point').item.json.chain_context.correlation_id }}
结果 string
"chain-7Hq2Lw9sKd3pXa1mZr4t"

链的根运行。

{{ $execution.id }}
结果 string
"fir-root-xxxx"

链中的这一跳。

{{ $execution.run_flow_instance_result_id }}
结果 string
"fir-hop-xxxx"

说明

  • 标签 Chain Entry Point 只是示例:$('…') 接收为 workflow.trigger 节点设置的标签。
  • 只有继续传递,chain_context 才会随之延续:workflow.chain 节点会为下一跳构建一个新的上下文,并自动向前携带根 id。

在 JSONata 中 $$json.chain_context.caller_flow_slug

示例上下文

示例基于以下数据运行:当前节点的输入($json)、已运行的节点($(…))、本次运行的 ID 以及当前节点。时钟固定为 2026-11-26T14:30:00.000Z,服务器时区为 UTC,因此各页面中 $now 与 $today 的值都相同。

当前节点的输入 JSON
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "ana.perez@example.com",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  }
}
已运行的节点(标签 → 输出) JSON
{
  "Webhook Receiver": "= $json",
  "Normalize input": {
    "correlation_id": "c-7f3a",
    "channel": "web"
  },
  "Classify": {
    "label": "billing",
    "confidence": 0.92
  }
}
运行与当前节点 JSON
{
  "$execution": {
    "id": "fir-xxxx",
    "flow_instance_id": "fi-xxxx",
    "flow_definition_id": "fd-xxxx",
    "flow_version_id": "fv-xxxx",
    "flow_slug": "order-intake"
  },
  "$node": {
    "id": "node-notify",
    "label": "Notify customer"
  }
}

串联工作流的示例基于第二个上下文运行:一个由 workflow.chain 启动的工作流,其 workflow.trigger 节点的标签为 Chain Entry Point。

被串联的工作流(标注 chain 的示例) JSON
{
  "$json": {
    "order_id": "ord_1042",
    "customer_email": "ana.perez@example.com",
    "amount": 46,
    "chain_context": {
      "caller_flow_definition_id": "fd-caller-xxxx",
      "caller_flow_instance_id": "fi-caller-xxxx",
      "caller_flow_slug": "order-intake",
      "caller_node_id": "node-chain-billing",
      "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
      "root_flow_instance_result_id": "fir-root-xxxx"
    }
  },
  "nodes": {
    "Chain Entry Point": {
      "order_id": "ord_1042",
      "customer_email": "ana.perez@example.com",
      "amount": 46,
      "chain_context": {
        "caller_flow_definition_id": "fd-caller-xxxx",
        "caller_flow_instance_id": "fi-caller-xxxx",
        "caller_flow_slug": "order-intake",
        "caller_node_id": "node-chain-billing",
        "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
        "root_flow_instance_result_id": "fir-root-xxxx"
      }
    }
  },
  "$execution": {
    "id": "fir-root-xxxx",
    "run_flow_instance_result_id": "fir-hop-xxxx",
    "flow_slug": "billing-review"
  }
}

示例运行所基于的编排器提交 31e874b

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

仅安装技能包,不会自动更新;需要时重新运行即可。

npx skills add https://docs.sommatic.ai
智能体如何读取本文档