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

Workflow Chain Receiver

接收来自其他工作流 Chain 节点的执行请求。

以 Markdown 查看
在以下应用中打开
触发器 可用 workflow.trigger 版本 1.0.0 执行方式: sync

由 workflow.chain 调用的子工作流的入口节点。可选择限制允许调用它的工作流,然后输出调用方发送的数据及 chain_context。

该触发器是被其他工作流通过 workflow.chain 节点调用时的入口。它支持对等的工作流链式调用,而无需建立父子层级。

功能特性:

  • 调用方过滤: 可选地限制哪些工作流可以链式调用本工作流。
  • 载荷透传: 调用方工作流的载荷在下游节点中以 $json 提供。
  • 可追溯性: 保留链式调用上下文(调用方实例、节点、关联 ID),用于审计。

适用场景:

  • 模块化组合工作流(例如由多个调用方共用的校验工作流)。
  • 事件驱动的链式调用:工作流 A 完成一个阶段后委派给工作流 B。
  • 可复用的子流程,且仍可独立测试和部署。

工作原理

  1. 触发来源:其他工作流中的 workflow.chain 节点。调用方为草稿运行(test)时,后端运行本工作流的草稿;调用方运行已发布版本(prod)时,运行默认的已发布版本;本工作流没有已发布版本时 prod 调用失败。运行输入为 { data, chain_context }。
  2. 解析节点配置。若 accepted_caller_ids 非空且 chain_context.caller_flow_definition_id 不在其中,则返回 error。
  3. 否则将 data 展开到根级,添加 chain_context,并在 meta 中返回调用方的定义 ID、slug、实例 ID 以及链路的关联 ID。

在工作流中

节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。

{
  "node_id": "node-from-parent",
  "label": "Called by order intake",
  "operator_slug": "workflow.trigger",
  "operator_version": "1.0.0",
  "config": {
    "accepted_caller_ids": [
      "<flow_definition_id>"
    ]
  }
}

配置

accepted_caller_ids array<string> 可选

选择允许调用本工作流的工作流。留空则接受任何工作流的调用。

默认值: []

配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。

代码中的行为

除 schema 描述之外,实现代码对这些键的实际处理。

accepted_caller_ids
与 chain_context.caller_flow_definition_id(工作流定义 ID,而非 slug)进行匹配。为空时接受所有调用方。

输出端口

out 默认

调用方被接受。

数据
{
  "order_id": "ord_123",
  "customer_email": "ana@example.com",
  "chain_context": {
    "caller_flow_definition_id": "<flow_definition_id>",
    "caller_flow_instance_id": "<flow_instance_id>",
    "caller_flow_slug": "order-intake",
    "caller_node_id": "node-call-billing",
    "correlation_id": "chain-8f2k1m9x0q4w7e3r5t6y",
    "root_flow_instance_result_id": "<flow_instance_result_id>"
  }
}
error

调用方不在 accepted_caller_ids 中。输出为信封 { ok, errors, port, meta: { rejected_caller_id, rejected_caller_slug } }。

数据
{
  "ok": false,
  "errors": [
    "Caller workflow 'order-intake' is not in the accepted callers list"
  ],
  "port": "error",
  "meta": {
    "rejected_caller_id": "<flow_definition_id>",
    "rejected_caller_slug": "order-intake"
  }
}

在表达式中

后续节点可通过 $("Workflow Chain Receiver").item.json.<路径> 读取此节点输出中的内容(请把 Workflow Chain Receiver 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。

表达式EditorWorker
$("Workflow Chain Receiver").item.json.dataobjectworker 不返回:读取结果为 undefined链式调用的输入数据。 —
$("Workflow Chain Receiver").item.json.chain_contextobject= {…}来自调用方的可追溯性元数据。
$("Workflow Chain Receiver").item.json.chain_context.caller_flow_definition_idstring= "<flow_definition_id>"
$("Workflow Chain Receiver").item.json.chain_context.caller_flow_instance_idstring= "<flow_instance_id>"
$("Workflow Chain Receiver").item.json.chain_context.caller_flow_slugstring= "order-intake"
$("Workflow Chain Receiver").item.json.chain_context.caller_node_idstring= "node-call-billing"
$("Workflow Chain Receiver").item.json.chain_context.correlation_idstring= "chain-8f2k1m9x0q4w7e3r5t6y"
$("Workflow Chain Receiver").item.json.order_idstring编辑器不提示= "ord_123"—
$("Workflow Chain Receiver").item.json.customer_emailstring编辑器不提示= "ana@example.com"—
$("Workflow Chain Receiver").item.json.chain_context.root_flow_instance_result_idstring编辑器不提示= "<flow_instance_result_id>"—

— Editor: 编辑器会提示它,但 worker 并不返回:读取结果为 undefined。

— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。

错误

消息 端口 原因与处理
Caller workflow '<caller_flow_slug or caller_flow_definition_id>' is not in the accepted callers list error 将调用方工作流的定义 ID 加入 accepted_caller_ids,或保持列表为空以接受任意调用方。列表非空时,未携带 chain_context 启动的运行(例如手动运行)同样会被拒绝。

输出契约

data object 可选

链式调用的输入数据。

chain_context object 可选

来自调用方的可追溯性元数据。

caller_flow_definition_id string 可选
caller_flow_instance_id string 可选
caller_flow_slug string 可选
caller_node_id string 可选
correlation_id string 可选

契约(JSON Schema)

与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。

{
  "slug": "workflow.trigger",
  "name": "Workflow Chain Receiver",
  "category": "triggers",
  "version": "1.0.0",
  "description": "Receives execution requests from another workflow's Chain node.\n\n  This trigger acts as the entry point for a workflow that is invoked by another workflow via the `workflow.chain` node. It enables peer-to-peer workflow chaining without creating a parent-child hierarchy.\n\n  **Features:**\n  - **Caller Filtering:** Optionally restrict which workflows can chain into this one.\n  - **Payload Passthrough:** The calling workflow's payload is available as `$json` in downstream nodes.\n  - **Traceability:** Chain context (caller instance, node, correlation ID) is preserved for audit.\n\n  **Use Cases:**\n  - Modular workflow composition (e.g., shared validation workflow invoked by multiple callers).\n  - Event-driven chaining where Workflow A completes a phase and delegates to Workflow B.\n  - Reusable sub-processes that remain independently testable and deployable.",
  "capabilities": [
    "workflow",
    "chain",
    "composition",
    "trigger"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "accepted_caller_ids": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "title": "Accepted Callers",
        "description": "Select which workflows are allowed to invoke this one. Leave empty to accept calls from any workflow.",
        "default": [],
        "x-ui-widget": "flow-definition-multi-picker"
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": null,
  "output_contract_schema": {
    "type": "object",
    "description": "The payload sent by the calling workflow.",
    "properties": {
      "data": {
        "type": "object",
        "description": "The chain input data."
      },
      "chain_context": {
        "type": "object",
        "description": "Traceability metadata from the caller.",
        "properties": {
          "caller_flow_definition_id": {
            "type": "string"
          },
          "caller_flow_instance_id": {
            "type": "string"
          },
          "caller_flow_slug": {
            "type": "string"
          },
          "caller_node_id": {
            "type": "string"
          },
          "correlation_id": {
            "type": "string"
          }
        }
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Received",
      "is_default": true,
      "description": "Chain payload received and validated."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Caller not authorized or validation failed."
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "workflow",
    "chain",
    "trigger",
    "composition"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

执行

执行方式
sync
有状态
否
重试(retryOnFail)
否
能力
workflowchaincompositiontrigger
标签
workflowchaintriggercomposition

说明与限制

  • 调用方数据的键会展开到根级,下游可通过 $json.<field> 读取;若 data 中含有 chain_context 键,会被真实的 chain_context 覆盖。
  • chain_context.root_flow_instance_result_id 在整条调用链的每一跳中保持不变,因此任何子工作流都能报告顶层运行的 ID。
  • 使用示例数据时,引擎会跳过本节点,经 out 原样输出示例输入(不会展开 data)。

已对照编排器代码核实 · 31e874b · 2026-11-26

安装智能体工具

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

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

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