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

Check Consent

检查用户是否已同意某项活动。

以 Markdown 查看
在以下应用中打开
身份 实验性 consent.check 版本 1.0.0 执行方式: async

占位用的同意检查:只校验 user_id 已设置,并始终以 consented: true 从 yes 输出。不会查询任何同意管理平台,也不会评估 purpose。

工作原理

  1. 解析配置:user_id 和 purpose 中的表达式基于当前运行求值。
  2. 当 user_id 为空时,以 user_id is required 从 error 输出。
  3. 不查询任何同意记录:决策在代码中固定为已同意。
  4. 从 yes 返回 { consented: true, timestamp },其中 timestamp 为求值时间(ISO 8601)。

在工作流中

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

{
  "node_id": "node-check-consent",
  "label": "Check marketing consent",
  "operator_slug": "consent.check",
  "operator_version": "1.0.0",
  "config": {
    "user_id": "{{ $json.customer_id }}",
    "purpose": "marketing_email"
  }
}

配置

user_id string 必填
purpose string 必填

代码中的行为

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

purpose
Schema 要求填写,但运行时会忽略:任何用途得到的结果都相同。

输出端口

yes 默认

只要设置了 user_id,始终从此端口输出。

数据
{
  "consented": true,
  "timestamp": "2026-11-26T15:04:05.000Z"
}
no

永远不会输出:worker 中没有拒绝同意的路径。

error

user_id 为空。

数据
{
  "error": "user_id is required"
}

在表达式中

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

表达式EditorWorker
$("Check Consent").item.json.consentedboolean= true
$("Check Consent").item.json.timestampstring= "2026-11-26T15:04:05.000Z"

错误

消息 端口 原因与处理
user_id is required error user_id 为空,或其表达式解析为空值。请对照输入项检查表达式。

输入契约

user_id string 必填
purpose string 必填

输出契约

consented boolean 可选
timestamp string 可选

契约(JSON Schema)

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

{
  "slug": "consent.check",
  "name": "Check Consent",
  "category": "identity",
  "version": "1.0.0",
  "description": "Checks if User has consented to activity.",
  "capabilities": [
    "privacy",
    "consent"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string"
      },
      "purpose": {
        "type": "string"
      }
    },
    "required": [
      "user_id",
      "purpose"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string"
      },
      "purpose": {
        "type": "string"
      }
    },
    "required": [
      "user_id",
      "purpose"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "consented": {
        "type": "boolean"
      },
      "timestamp": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "yes",
      "label": "Consented",
      "description": "User agreed",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "no",
      "label": "Not Consented",
      "description": "User did not agree",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Check failed",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "identity-worker"
  ],
  "tags": [
    "privacy",
    "gdpr"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_veripass",
    "profile": {
      "name": "Veripass",
      "verified": true,
      "url": "https://me.veripass.com/veripass",
      "logo_url": null
    }
  }
}

执行

执行方式
async
有状态
否
能力
privacyconsent
标签
privacygdpr

说明与限制

  • 不要依赖此节点执行同意管控:它从不走 no。在接入真实的同意数据源之前,请用显式调用(例如 io.http)加 flow.if 来检查。
  • 从 error 端口输出不会使运行失败:引擎沿 error 上的连线继续;若没有连线,该分支直接结束。

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

安装智能体工具

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

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

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