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

Vectry Event Subscription

根据系统内部事件(Event Bus)触发工作流执行。

以 Markdown 查看
在以下应用中打开
触发器 实验性 event.trigger 版本 1.0.0 执行方式: async

事件驱动工作流的入口节点。它将运行输入整理为 { event_id, source, type, payload };当前版本不会订阅事件总线,过滤条件也不会生效。

该触发器订阅 Vectry Causal Event Bus。它监听特定的业务或系统事件(例如“Order Created”“User Signup”),并在出现匹配事件时启动工作流。

功能特性:

  • 过滤: 只订阅符合特定条件(domain、entity、tag)的事件。
  • 回放: 处理历史事件(“since”)或只处理新事件。
  • 模式匹配: 在复杂事件序列上触发(如已配置)。

适用场景:

  • 出现“UserCreated”事件时发送欢迎邮件。
  • 审计高额交易。

工作原理

  1. 触发来源:当前版本中没有后端组件为本节点订阅事件总线。只有在以事件结构的输入显式启动工作流(手动运行或执行请求)时才会运行。
  2. 按原样读取输入项;不读取也不解析节点配置。
  3. 输出 event_id(默认 unknown)、source(默认 vectry)、type(默认 unknown)和 payload:若输入中有 payload 字段则取该字段,否则取整个输入。

在工作流中

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

{
  "node_id": "node-order-created",
  "label": "Order created",
  "operator_slug": "event.trigger",
  "operator_version": "1.0.0",
  "config": {
    "filters": [
      {
        "system_domain": "sales",
        "system_entity": "order",
        "operation": "created"
      }
    ],
    "since": "now"
  }
}

配置

filters array<object> 必填

事件匹配条件。

since string 可选

时间戳(ISO)或“now”。

默认值: now

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

代码中的行为

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

filters
在 schema 中已声明且为必填,但不会被读取:不会进行任何事件过滤。since 同样不会被读取。

输出端口

out 默认

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

数据
{
  "event_id": "evt_01JDX4Q8M2",
  "source": "vectry",
  "type": "order.created",
  "payload": {
    "order_id": "ord_123",
    "total": 129.99,
    "currency": "USD"
  }
}
error

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

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

在表达式中

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

表达式EditorWorker
$("Vectry Event Subscription").item.json.event_idstring= "evt_01JDX4Q8M2"
$("Vectry Event Subscription").item.json.sourcestring= "vectry"
$("Vectry Event Subscription").item.json.typestring= "order.created"
$("Vectry Event Subscription").item.json.payloadobject= {…}
$("Vectry Event Subscription").item.json.payload.order_idstring编辑器不提示= "ord_123"—
$("Vectry Event Subscription").item.json.payload.totalnumber编辑器不提示= 129.99—
$("Vectry Event Subscription").item.json.payload.currencystring编辑器不提示= "USD"—

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

输出契约

event_id string 可选
source string 可选
type string 可选
payload object 可选

契约(JSON Schema)

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

{
  "slug": "event.trigger",
  "name": "Vectry Event Subscription",
  "category": "triggers",
  "version": "1.0.0",
  "description": "Trigger workflow execution based on internal system events (Event Bus).\n\n  This trigger subscribes to the Vectry Causal Event Bus. It listens for specific business or system events (e.g., \"Order Created\", \"User Signup\") and initiates the workflow when a matching event occurs.\n\n  **Features:**\n  - **Filtering:** Subscribe only to events matching specific criteria (domain, entity, tag).\n  - **Replay:** Process historical events (\"since\") or only new ones.\n  - **Pattern Matching:** Trigger on complex event sequences (if configured).\n\n  **Use Cases:**\n  - Sending a Welcome Email when a 'UserCreated' event occurs.\n  - Auditing high-value transactions.",
  "capabilities": [
    "event-subscription",
    "internal-bus",
    "pubsub",
    "vectry"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "filters"
    ],
    "properties": {
      "filters": {
        "type": "array",
        "title": "Event Filters",
        "description": "Match criteria for events.",
        "items": {
          "type": "object",
          "properties": {
            "system_domain": {
              "type": "string",
              "title": "Domain"
            },
            "system_entity": {
              "type": "string",
              "title": "Entity"
            },
            "operation": {
              "type": "string",
              "title": "Operation"
            },
            "tags": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "since": {
        "type": "string",
        "title": "Start From",
        "default": "now",
        "description": "Timestamp (ISO) or \"now\"."
      },
      "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 event payload.",
    "properties": {
      "event_id": {
        "type": "string"
      },
      "source": {
        "type": "string"
      },
      "type": {
        "type": "string"
      },
      "payload": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Event Received",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "async",
  "tags": [
    "vectry",
    "events",
    "bus",
    "reactive"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

执行

执行方式
async
有状态
否
重试(retryOnFail)
否
能力
event-subscriptioninternal-buspubsubvectry
标签
vectryeventsbusreactive

说明与限制

  • 可将本节点视为带类型的入口:以 { event_id, source, type, payload } 启动工作流,并在下游通过 $json.payload 读取事件数据。
  • 使用示例数据时,引擎会跳过本节点,并经 out 原样输出示例输入。

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

安装智能体工具

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

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

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