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

Manual / Ad-Hoc Trigger

允许用户或管理员手动启动工作流。

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

用于手动或通过执行请求启动的工作流的入口节点。它将 payload_template 与输入合并,结果同时放在 manual_payload 和根级输出中,并附带 triggered_by 和 timestamp。

该触发器为工作流定义“启动按钮”。它常用于测试、调试,或需要人工显式发起的工作流(例如“运行月末报表”)。

功能特性:

  • 表单输入: 可以为用户点击“Run”时必须提供的输入载荷定义 schema。
  • 测试: 非常适合用多组不同的测试数据集验证逻辑。

适用场景:

  • 启动一次性的数据库迁移脚本。
  • 用模拟客户数据测试新的工作流。

工作原理

  1. 触发来源:在编辑器中运行,或携带输入的执行请求。运行草稿为测试运行;运行已发布版本为生产运行。
  2. 解析节点配置并合并 { ...payload_template, ...input }:输入中的键优先于模板。
  3. 经 out 输出 { triggered_by, timestamp, manual_payload, ...merged }。

在工作流中

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

{
  "node_id": "node-start",
  "label": "Run report",
  "operator_slug": "manual.trigger",
  "operator_version": "1.0.0",
  "config": {
    "payload_template": {
      "region": "north"
    }
  }
}

配置

payload_template object 可选

自动预填手动输入表单,方便使用。

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

代码中的行为

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

payload_template
作为默认值与输入合并(输入优先)。若某键与 triggered_by、timestamp 或 manual_payload 同名,合并后的值会在根级覆盖它们。

输出端口

out 默认

总是从此端口输出,除非发生意外异常。

数据
{
  "triggered_by": "manual",
  "timestamp": "2026-11-26T09:15:42.008-05:00",
  "manual_payload": {
    "period": "2026-10",
    "region": "north"
  },
  "period": "2026-10",
  "region": "north"
}
error

仅在发生意外异常时输出,内容为 { error, response }。正常使用中不会出现。

数据
{
  "error": "<exception message>",
  "response": null
}

在表达式中

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

表达式EditorWorker
$("Manual / Ad-Hoc Trigger").item.json.triggered_bystring= "manual"点击 Run 的用户。
$("Manual / Ad-Hoc Trigger").item.json.timestampstring= "2026-11-26T09:15:42.008-05:00"
$("Manual / Ad-Hoc Trigger").item.json.manual_payloadobject= {…}用户输入的数据。
$("Manual / Ad-Hoc Trigger").item.json.manual_payload.periodstring编辑器不提示= "2026-10"—
$("Manual / Ad-Hoc Trigger").item.json.manual_payload.regionstring编辑器不提示= "north"—
$("Manual / Ad-Hoc Trigger").item.json.periodstring编辑器不提示= "2026-10"—
$("Manual / Ad-Hoc Trigger").item.json.regionstring编辑器不提示= "north"—

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

输出契约

triggered_by string 可选

点击 Run 的用户。

timestamp string 可选
manual_payload object 可选

用户输入的数据。

契约(JSON Schema)

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

{
  "slug": "manual.trigger",
  "name": "Manual / Ad-Hoc Trigger",
  "category": "triggers",
  "version": "1.0.0",
  "description": "Allows a workflow to be started manually by a user or administrator.\n\n  This trigger defines the \"Start Button\" for a workflow. It is commonly used for testing, debugging, or workflows that require explicit human initiation (e.g., \"Run End of Month Report\").\n\n  **Features:**\n  - **Form Input:** Can define a schema for the input payload the user must provide when clicking \"Run\".\n  - **Testing:** Ideal for validating logic with disparate test datasets.\n\n  **Use Cases:**\n  - Launching a one-off database migration script.\n  - Testing a new workflow with mock customer data.",
  "capabilities": [
    "testing",
    "ad-hoc",
    "manual",
    "ui"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "payload_template": {
        "type": "object",
        "title": "Default/Sample Payload",
        "description": "Auto-fills the manual input form for convenience."
      },
      "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",
    "properties": {
      "triggered_by": {
        "type": "string",
        "description": "User who clicked Run."
      },
      "timestamp": {
        "type": "string",
        "format": "date-time"
      },
      "manual_payload": {
        "type": "object",
        "description": "Data entered by user."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Started",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "test",
    "manual",
    "debug",
    "start"
  ],
  "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)
否
能力
testingad-hocmanualui
标签
testmanualdebugstart

说明与限制

  • triggered_by 始终为 manual:启动运行的用户不会传入本节点。
  • timestamp 为编排器本地时间,采用 ISO 格式。
  • 当工作流保存了触发器状态或键值状态时,后端会将 $trigger_state / $kv_state 加入输入,因此它们也会出现在输出中。
  • 使用示例数据时,引擎会跳过本节点,经 out 原样输出示例输入,不包含 triggered_by、timestamp 和 manual_payload。

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

安装智能体工具

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

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

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