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

Webhook Receiver

监听外部 HTTP 请求以触发工作流。

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

由 HTTP 调用启动的工作流的入口节点。它会校验请求方法和可选的共享密钥,然后输出请求的 headers、body、query 和 method。

该算子暴露一个唯一的 URL 端点。当外部服务(例如 Stripe、Typeform、GitHub)向该 URL 发送 POST 请求时,工作流会以请求正文作为载荷进行实例化。

功能特性:

  • 不限方法: 可配置为接受 POST、GET、PUT。
  • 认证: 支持校验请求头或签名/密钥。
  • 响应: 可定义返回给调用方的响应(同步或异步)。

适用场景:

  • 集成表单提交(Typeform)。
  • 响应支付事件(Stripe Webhook)。
  • 构建自定义 API 端点。

工作原理

  1. 触发来源:向后端 /workflow-orchestration/trigger/webhooks/{mode}/{bindingIdentifier} 发送 POST,其中 bindingIdentifier 是指向该工作流的入口绑定(ingress binding)ID 或 slug。请求体上限为 5 MB。默认同步执行;在查询串或请求体中设置 execution_mode=async 时会立即返回实例 ID。
  2. mode 为 test 时运行工作流草稿;为 prod 时运行默认的已发布版本(或最新版本),没有已发布版本时失败。请求会成为运行输入 { body, headers, query, method }。
  3. 节点解析配置,并将请求方法(转为大写,默认 GET)与 method(默认 POST)比较,method 为 ANY 时跳过比较。
  4. 校验 auth_type:none(默认);header 将名为 auth_config.header_name 的请求头与 auth_config.secret 比较;basic 将完整的 Authorization 请求头与 auth_config.secret 比较;其他值一律拒绝。
  5. 经 out 输出 { headers, body, query, method },并附带 meta.reply_mode。

在工作流中

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

{
  "node_id": "node-webhook",
  "label": "Order webhook",
  "operator_slug": "webhook.trigger",
  "operator_version": "1.0.0",
  "config": {
    "method": "POST",
    "auth_type": "header",
    "auth_config": {
      "header_name": "x-webhook-token",
      "secret": "<shared-secret>"
    }
  }
}

配置

method string 可选

默认值: POST

可选值: POSTGETPUTPATCHDELETE

path string 可选

自定义路径段(例如 /my-hook)。

response_mode string 可选

Immediate:立即返回 200 OK。Workflow End:等待工作流结束后返回结果。

默认值: immediate

可选值: immediateworkflow_end

代码中的行为

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

auth_type 代码会读取,但未声明
未声明,auth_config(header_name、secret)和 reply_mode(默认 sync,仅回显在 meta 中)同样未声明。取值按普通字符串比较;basic 不会解码请求头。
method
代码还接受 schema 枚举中没有的 ANY。由于后端路由只支持 POST,请保持 POST 或 ANY。
path
已声明但不会被读取:URL 由入口绑定决定。response_mode 同样不会被读取;如需立即响应,请在调用时使用 execution_mode=async。

输出端口

out 默认

方法和认证校验均通过。请求头名称为小写。

数据
{
  "headers": {
    "content-type": "application/json",
    "user-agent": "curl/8.7.1"
  },
  "body": {
    "event": "order.received",
    "data": {
      "order_id": "ord_123",
      "total": 129.99
    }
  },
  "query": {},
  "method": "POST"
}
error

方法或认证校验失败。输出为信封 { ok, errors, port, meta: { status_code } };status_code(405 或 401)仅供参考,不会改变该调用的 HTTP 响应。

数据
{
  "ok": false,
  "errors": [
    "Authentication Failed: Invalid header secret"
  ],
  "port": "error",
  "meta": {
    "status_code": 401
  }
}

在表达式中

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

表达式EditorWorker
$("Webhook Receiver").item.json.bodyobject= {…}
$("Webhook Receiver").item.json.headersobject= {…}
$("Webhook Receiver").item.json.queryobject= {…}
$("Webhook Receiver").item.json.headers.content-typestring编辑器不提示= "application/json"—
$("Webhook Receiver").item.json.headers.user-agentstring编辑器不提示= "curl/8.7.1"—
$("Webhook Receiver").item.json.body.eventstring编辑器不提示= "order.received"—
$("Webhook Receiver").item.json.body.dataobject编辑器不提示= {…}—
$("Webhook Receiver").item.json.methodstring编辑器不提示= "POST"—

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

错误

消息 端口 原因与处理
Method Not Allowed: Expected <method>, got <incoming> error method 不是 POST 或 ANY。入口路由只接受 POST,因此其他取值总会失败。
Authentication Failed: Invalid header secret error auth_type 为 header,但请求头缺失或不一致。Authentication Failed: Invalid basic auth 是 basic 方式的对应错误。
Authentication Failed: Auth type <auth_type> not implemented error auth_type 不是 none、header 或 basic(例如 jwt 或 hmac)。
No published version found for this workflow error 由后端在节点运行前返回:对从未发布的工作流发起了 prod 调用。Webhook binding not found 表示绑定 ID 或 slug 错误。

输出契约

body object 可选
headers object 可选
query object 可选

契约(JSON Schema)

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

{
  "slug": "webhook.trigger",
  "name": "Webhook Receiver",
  "category": "triggers",
  "version": "1.0.0",
  "description": "Listens for external HTTP requests to trigger the workflow.\n\n  This operator exposes a unique URL endpoint. When an external service (e.g., Stripe, Typeform, GitHub) sends a POST request to this URL, the workflow is instantiated with the request body as the payload.\n\n  **Features:**\n  - **Method Agnostic:** Can be configured to accept POST, GET, PUT.\n  - **Authentication:** Supports validating headers or signatures/secrets.\n  - **Response:** Can define what response to send back to the caller (Sync vs Async).\n\n  **Use Cases:**\n  - Integrating form submissions (Typeform).\n  - Reacting to payment events (Stripe Webhook).\n  - Building a custom API endpoint.",
  "capabilities": [
    "http",
    "webhook",
    "api",
    "ingress"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "method": {
        "type": "string",
        "enum": [
          "POST",
          "GET",
          "PUT",
          "PATCH",
          "DELETE"
        ],
        "default": "POST",
        "title": "HTTP Method"
      },
      "path": {
        "type": "string",
        "title": "Route Path",
        "description": "Custom path segment (e.g. /my-hook)."
      },
      "response_mode": {
        "type": "string",
        "enum": [
          "immediate",
          "workflow_end"
        ],
        "default": "immediate",
        "description": "Immediate: Returns 200 OK instantly. Workflow End: Waits for workflow to finish and returns result."
      }
    }
  },
  "input_contract_schema": null,
  "output_contract_schema": {
    "type": "object",
    "description": "The incoming HTTP request data.",
    "properties": {
      "body": {
        "type": "object"
      },
      "headers": {
        "type": "object"
      },
      "query": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Received",
      "is_default": true,
      "description": "Request received."
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "async",
  "tags": [
    "http",
    "api",
    "webhook",
    "trigger"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

执行

执行方式
async
有状态
否
能力
httpwebhookapiingress
标签
httpapiwebhooktrigger

说明与限制

  • 入口端点本身不做认证,安全性取决于本节点的 auth_type 和绑定配置。校验失败时仍会创建一次运行,并结束于 error。
  • 已暂停的工作流不会运行:test 模式下调用返回 423,prod 模式下返回 200 并生成一个暂停状态的实例。在编辑器中使用示例数据时,引擎会跳过本节点并经 out 输出示例输入。
  • 在下游可通过 {{ $json.body.<field> }} 读取请求内容。

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

安装智能体工具

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

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

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