Create Task
在 Work Management 系统中创建一项人工任务。
在 Sommatic AI 后端的 Work Management 中创建任务,并立即从 created 继续;运行不会等待人员处理。
工作原理
- 解析配置并合并到输入 payload 之上:每个字段都可来自配置或 payload 中的同名键(配置优先)。
- 检查
organization_id、title、type.name和priority.name。 - 选取双模式值:负责人取
assignee(assignee_mode为specific_user)或assignee_custom(custom);项目取project_id(picker)或project_id_expression(expression);截止时间取due_at(picker)或due_at_expression(expression)。 - 构建
sla:截止时间(ISO 8601 或纪元毫秒)转换为{ due_at: "<纪元毫秒>", sla_ms: <截止 - 当前>, is_overdue };配置了sla_ms时替换计算值;无法解析的截止时间按原样保存。 - 构建任务:
status为queued,source为workflow,负责人为{ assignee_type: "user", user: { identity, profile: { primary_email_address: identity } } }(或null),以及payload{ summary, evidence, linked_entities }、required_output、outputs和context.reminders。 - 提交到后端 Work Management 任务 API。有用户负责人时,后端会为该用户认领任务(状态
claimed);没有时保持queued,按project_id划定范围。 - 通过
created返回{ task_id, task_title, task_type, has_hag, status }。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-review-refund",
"label": "Review refund",
"operator_slug": "human.task.create",
"operator_version": "1.0.0",
"config": {
"organization_id": "<organization_id>",
"title": "Review refund for {{ $json.order_id }}",
"description": "Customer requested a refund of {{ $json.amount }}.",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"assignee_mode": "specific_user",
"assignee": "[email protected]",
"due_at_mode": "expression",
"due_at_expression": "{{ $now.plus({ days: 2 }).toISO() }}",
"reminders": true,
"payload": {
"summary": "Refund request for {{ $json.order_id }}",
"evidence": [],
"linked_entities": []
},
"has_hag": true
}
}{
"ok": true,
"port": "created",
"task_id": "task-xxxxxxxxxxxxxxx",
"task_title": "Review refund for ord_123",
"task_type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"has_hag": true,
"status": {
"id": 5,
"name": "claimed",
"title": "Claimed",
"color": "#5e35b1"
}
}配置
-
organization_idstring 必填 -
拥有该任务的组织 ID
-
titlestring 必填 支持表达式 -
简短摘要。支持 {{ $json.title }} 等表达式。
-
descriptionstring 可选 支持表达式 -
给处理人的详细说明。支持表达式和多行文本。
-
typeobject 必填 -
Approval | Data Completion | Review | Resolution | Delegation
-
priorityobject 必填 -
project_modestring 可选 -
Picker:选择一个项目。Expression:动态推导项目 ID(例如按接收邮箱推导)。
-
project_idstring 可选 -
该任务所属的项目(决定可见范围和分组)。
-
project_id_expressionstring 可选 支持表达式 -
返回项目 ID 字符串。示例:{{ $json.project_id }}。
-
assignee_modestring 可选 -
Specific User:从组织中选择。Custom:提供身份标识或表达式。
-
assigneestring 可选 -
接收该任务的单个用户
-
assignee_customstring 可选 支持表达式 -
使用 {{ $json.user_id }} 或字面身份字符串。
-
due_at_modestring 可选 -
due_atstring 可选 -
以 Unix 毫秒字符串存储。
-
due_at_expressionstring 可选 支持表达式 -
返回 ISO 8601 或 Unix 毫秒。示例:{{ $now.plus({days: 3}).toISO() }}
-
sla_msinteger 可选 -
可选。任务分配后允许完成的时长。
-
remindersboolean 可选 -
required_outputobject 可选 -
描述处理人完成时必须提供的数据的 JSON Schema,以及用于渲染表单的 UI 提示。
-
outputsobject 可选 -
可选。由上游节点(例如分类器或解析器)预先生成、由人工仅做核验、编辑或驳回的自由结构答案。映射到 Task.outputs。不同于“Payload”(后者是面向操作员的上下文:summary + evidence + linked_entities)。
-
payloadobject 可选 -
传给处理人作为上下文的摘要、证据块和关联实体。
-
has_hagboolean 可选 -
需要下游的 Human Approval Gate 节点。
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
type - 来自后端目录的对象
{ id, name, title, color }:approval(10)、data_completion(11)、review(12)、resolution(13)、delegation(14)。worker 只检查name是否存在。 -
priority - 来自目录的对象:
low(1)、medium(2)、high(3)、critical(4)。 -
assignee - 用户身份;它也会被存为该用户的主邮箱,因此请使用邮箱身份。只会生成用户类型的负责人:本节点不支持用户组。
-
payload - 只保留
summary、evidence(数组)和linked_entities(数组)。未配置payload时,这些键从输入 payload 读取。也会读取旧别名task_payload、task_required_output和task_outputs。 -
has_hag - 仅在输出中回显。为 true 时,编辑器要求紧接一个
human.approval.gate节点。
输出端口
created 默认 后端返回了任务 id。status 为后端返回的状态对象。
{
"port": "created",
"task_id": "task-xxxxxxxxxxxxxxx",
"task_title": "Review refund for ord_123",
"task_type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"has_hag": true,
"status": {
"id": 5,
"name": "claimed",
"title": "Claimed",
"color": "#5e35b1"
}
}error 缺少必填字段或后端调用失败。
{
"port": "error",
"error": "Missing 'title'"
}在表达式中
后续节点可通过 $("Create Task").item.json.<路径> 读取此节点输出中的内容(请把 Create Task 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 created 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Create Task").item.json.task_id | ||
$("Create Task").item.json.task_title | ||
$("Create Task").item.json.task_type | ||
$("Create Task").item.json.has_hag | ||
$("Create Task").item.json.status | ||
$("Create Task").item.json.port | — | |
$("Create Task").item.json.task_type.id | — | |
$("Create Task").item.json.task_type.name | — | |
$("Create Task").item.json.task_type.title | — | |
$("Create Task").item.json.task_type.color | — | |
$("Create Task").item.json.status.id | — | |
$("Create Task").item.json.status.name | — | |
$("Create Task").item.json.status.title | — | |
$("Create Task").item.json.status.color | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
Missing 'organization_id' | error | 配置和 payload 中都没有。它不会取自运行身份。 |
Missing 'title' | error | 解析表达式后 title 为空。 |
Missing 'type' or invalid type object | error | type 缺失或没有 name。 |
Missing 'priority' or invalid priority object | error | priority 缺失或没有 name。 |
Backend did not return a task id | error | 后端响应中没有 result.id。 |
Request failed with status code <status> | error | 后端拒绝了该任务。 |
services.apiManager.uri is not resolved in dependencies.config — check Link Loom Cloud environment config. | error | 编排器未配置后端地址。这是服务配置问题,与节点无关。 |
输入契约
-
organization_idstring 可选 -
titlestring 可选 -
descriptionstring 可选 -
typeobject 可选 -
priorityobject 可选 -
project_modestring 可选 -
project_idstring 可选 -
project_id_expressionstring 可选 -
assignee_modestring 可选 -
assigneestring 可选 -
assignee_customstring 可选 -
due_at_modestring 可选 -
due_atstring 可选 -
due_at_expressionstring 可选 -
sla_msinteger 可选 -
remindersboolean 可选 -
required_outputobject 可选 -
outputsobject 可选 -
payloadobject 可选 -
has_hagboolean 可选
输出契约
-
task_idstring 可选 -
task_titlestring 可选 -
task_typeobject 可选 -
has_hagboolean 可选 -
statusstring 可选
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "human.task.create",
"name": "Create Task",
"category": "hitl",
"version": "1.0.0",
"description": "Creates a human task in the Work Management system.",
"capabilities": [
"task",
"human",
"workflow"
],
"config_schema": {
"type": "object",
"required": [
"title",
"organization_id",
"type",
"priority"
],
"properties": {
"organization_id": {
"type": "string",
"title": "Organization",
"description": "Organization ID that owns this task",
"default_from": "auth.organization_id"
},
"title": {
"type": "string",
"title": "Task Title",
"format": "expression",
"description": "Short summary. Supports expressions like {{ $json.title }}."
},
"description": {
"type": "string",
"title": "Description",
"format": "expression",
"description": "Detailed instructions for the assignee. Supports expressions and multi-line text."
},
"type": {
"type": "object",
"title": "Task Type",
"ui_widget": "task_type_picker",
"description": "Approval | Data Completion | Review | Resolution | Delegation"
},
"priority": {
"type": "object",
"title": "Priority",
"ui_widget": "task_priority_picker",
"default": {
"id": 2,
"name": "medium",
"title": "Medium",
"color": "#1976d2"
}
},
"project_mode": {
"type": "string",
"title": "Project mode",
"enum": [
"picker",
"expression"
],
"default": "picker",
"description": "Picker: select a project. Expression: derive the project id dynamically (e.g. by ingress mailbox)."
},
"project_id": {
"type": "string",
"title": "Project",
"ui_widget": "project_picker",
"description": "Project this task belongs to (scopes visibility and grouping).",
"displayOptions": {
"show": {
"project_mode": [
"picker"
]
}
}
},
"project_id_expression": {
"type": "string",
"title": "Project id expression",
"format": "expression",
"description": "Return a project id string. Example: {{ $json.project_id }}.",
"displayOptions": {
"show": {
"project_mode": [
"expression"
]
}
}
},
"assignee_mode": {
"type": "string",
"title": "Assignee mode",
"enum": [
"specific_user",
"custom"
],
"default": "specific_user",
"description": "Specific User: pick from your organization. Custom: provide an identity or expression."
},
"assignee": {
"type": "string",
"title": "User",
"ui_widget": "user_picker",
"ui_options": {
"allow_assign_to_me": true
},
"description": "Single user the task will be assigned to",
"displayOptions": {
"show": {
"assignee_mode": [
"specific_user"
]
}
}
},
"assignee_custom": {
"type": "string",
"title": "Custom assignee (identity or expression)",
"format": "expression",
"description": "Use {{ $json.user_id }} or a literal identity string.",
"displayOptions": {
"show": {
"assignee_mode": [
"custom"
]
}
}
},
"due_at_mode": {
"type": "string",
"title": "Due date source",
"enum": [
"picker",
"expression"
],
"default": "picker"
},
"due_at": {
"type": "string",
"title": "Due Date",
"format": "date-time",
"description": "Stored as Unix milliseconds string.",
"displayOptions": {
"show": {
"due_at_mode": [
"picker"
]
}
}
},
"due_at_expression": {
"type": "string",
"title": "Due date expression",
"format": "expression",
"description": "Return ISO 8601 or Unix millis. Example: {{ $now.plus({days: 3}).toISO() }}",
"displayOptions": {
"show": {
"due_at_mode": [
"expression"
]
}
}
},
"sla_ms": {
"type": "integer",
"title": "SLA duration (ms)",
"description": "Optional. Time allowed to complete the task once assigned.",
"default": 86400000
},
"reminders": {
"type": "boolean",
"title": "Enable Reminders",
"default": true
},
"required_output": {
"type": "object",
"title": "Required Output",
"description": "JSON Schema describing the data the assignee must provide on completion, plus UI hints for rendering the form."
},
"outputs": {
"type": "object",
"title": "Pre-computed Outputs",
"description": "Optional. Free-schema answer already produced by an upstream node (e.g. classifier or resolver) that the human merely verifies, edits, or rejects. Maps to Task.outputs. Distinct from \"Payload\" (which is the operator-facing context: summary + evidence + linked_entities)."
},
"payload": {
"type": "object",
"title": "Payload",
"description": "Summary, evidence blocks and linked entities passed to the assignee for context."
},
"has_hag": {
"type": "boolean",
"title": "Has Human Approval",
"description": "Requires a downstream Human Approval Gate node.",
"default": false
},
"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": {
"type": "object",
"properties": {
"organization_id": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"type": {
"type": "object"
},
"priority": {
"type": "object"
},
"project_mode": {
"type": "string"
},
"project_id": {
"type": "string"
},
"project_id_expression": {
"type": "string"
},
"assignee_mode": {
"type": "string"
},
"assignee": {
"type": "string"
},
"assignee_custom": {
"type": "string"
},
"due_at_mode": {
"type": "string"
},
"due_at": {
"type": "string"
},
"due_at_expression": {
"type": "string"
},
"sla_ms": {
"type": "integer"
},
"reminders": {
"type": "boolean"
},
"required_output": {
"type": "object"
},
"outputs": {
"type": "object"
},
"payload": {
"type": "object"
},
"has_hag": {
"type": "boolean"
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string"
},
"task_title": {
"type": "string"
},
"task_type": {
"type": "object"
},
"has_hag": {
"type": "boolean"
},
"status": {
"type": "string"
}
}
},
"ports": [
{
"port_id": "created",
"label": "Created",
"is_default": true,
"description": "Task successfully created"
},
{
"port_id": "error",
"label": "Error"
}
],
"chain_constraints": {
"next": [
{
"when": {
"has_hag": true
},
"required_slug": "human.approval.gate",
"message": "When \"Has Human Approval\" is checked, this node must be followed by a Human Approval Gate node."
}
]
},
"execution_mode": "async",
"tags": [
"human",
"task",
"management"
],
"is_stateful": true,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"title",
"organization_id",
"type",
"priority"
],
"properties": {
"organization_id": {
"type": "string",
"title": "Organization",
"description": "Organization ID that owns this task",
"default_from": "auth.organization_id"
},
"title": {
"type": "string",
"title": "Task Title",
"format": "expression",
"description": "Short summary. Supports expressions like {{ $json.title }}."
},
"description": {
"type": "string",
"title": "Description",
"format": "expression",
"description": "Detailed instructions for the assignee. Supports expressions and multi-line text."
},
"type": {
"type": "object",
"title": "Task Type",
"ui_widget": "task_type_picker",
"description": "Approval | Data Completion | Review | Resolution | Delegation"
},
"priority": {
"type": "object",
"title": "Priority",
"ui_widget": "task_priority_picker",
"default": {
"id": 2,
"name": "medium",
"title": "Medium",
"color": "#1976d2"
}
},
"project_mode": {
"type": "string",
"title": "Project mode",
"enum": [
"picker",
"expression"
],
"default": "picker",
"description": "Picker: select a project. Expression: derive the project id dynamically (e.g. by ingress mailbox)."
},
"project_id": {
"type": "string",
"title": "Project",
"ui_widget": "project_picker",
"description": "Project this task belongs to (scopes visibility and grouping).",
"displayOptions": {
"show": {
"project_mode": [
"picker"
]
}
}
},
"project_id_expression": {
"type": "string",
"title": "Project id expression",
"format": "expression",
"description": "Return a project id string. Example: {{ $json.project_id }}.",
"displayOptions": {
"show": {
"project_mode": [
"expression"
]
}
}
},
"assignee_mode": {
"type": "string",
"title": "Assignee mode",
"enum": [
"specific_user",
"custom"
],
"default": "specific_user",
"description": "Specific User: pick from your organization. Custom: provide an identity or expression."
},
"assignee": {
"type": "string",
"title": "User",
"ui_widget": "user_picker",
"ui_options": {
"allow_assign_to_me": true
},
"description": "Single user the task will be assigned to",
"displayOptions": {
"show": {
"assignee_mode": [
"specific_user"
]
}
}
},
"assignee_custom": {
"type": "string",
"title": "Custom assignee (identity or expression)",
"format": "expression",
"description": "Use {{ $json.user_id }} or a literal identity string.",
"displayOptions": {
"show": {
"assignee_mode": [
"custom"
]
}
}
},
"due_at_mode": {
"type": "string",
"title": "Due date source",
"enum": [
"picker",
"expression"
],
"default": "picker"
},
"due_at": {
"type": "string",
"title": "Due Date",
"format": "date-time",
"description": "Stored as Unix milliseconds string.",
"displayOptions": {
"show": {
"due_at_mode": [
"picker"
]
}
}
},
"due_at_expression": {
"type": "string",
"title": "Due date expression",
"format": "expression",
"description": "Return ISO 8601 or Unix millis. Example: {{ $now.plus({days: 3}).toISO() }}",
"displayOptions": {
"show": {
"due_at_mode": [
"expression"
]
}
}
},
"sla_ms": {
"type": "integer",
"title": "SLA duration (ms)",
"description": "Optional. Time allowed to complete the task once assigned.",
"default": 86400000
},
"reminders": {
"type": "boolean",
"title": "Enable Reminders",
"default": true
},
"required_output": {
"type": "object",
"title": "Required Output",
"description": "JSON Schema describing the data the assignee must provide on completion, plus UI hints for rendering the form."
},
"outputs": {
"type": "object",
"title": "Pre-computed Outputs",
"description": "Optional. Free-schema answer already produced by an upstream node (e.g. classifier or resolver) that the human merely verifies, edits, or rejects. Maps to Task.outputs. Distinct from \"Payload\" (which is the operator-facing context: summary + evidence + linked_entities)."
},
"payload": {
"type": "object",
"title": "Payload",
"description": "Summary, evidence blocks and linked entities passed to the assignee for context."
},
"has_hag": {
"type": "boolean",
"title": "Has Human Approval",
"description": "Requires a downstream Human Approval Gate node.",
"default": false
},
"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
}
}
}
}
}{
"type": "object",
"properties": {
"organization_id": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"type": {
"type": "object"
},
"priority": {
"type": "object"
},
"project_mode": {
"type": "string"
},
"project_id": {
"type": "string"
},
"project_id_expression": {
"type": "string"
},
"assignee_mode": {
"type": "string"
},
"assignee": {
"type": "string"
},
"assignee_custom": {
"type": "string"
},
"due_at_mode": {
"type": "string"
},
"due_at": {
"type": "string"
},
"due_at_expression": {
"type": "string"
},
"sla_ms": {
"type": "integer"
},
"reminders": {
"type": "boolean"
},
"required_output": {
"type": "object"
},
"outputs": {
"type": "object"
},
"payload": {
"type": "object"
},
"has_hag": {
"type": "boolean"
}
}
}{
"type": "object",
"properties": {
"task_id": {
"type": "string"
},
"task_title": {
"type": "string"
},
"task_type": {
"type": "object"
},
"has_hag": {
"type": "boolean"
},
"status": {
"type": "string"
}
}
}[
{
"port_id": "created",
"label": "Created",
"is_default": true,
"description": "Task successfully created"
},
{
"port_id": "error",
"label": "Error"
}
]执行
- 执行方式
async- 有状态
- 是
- 重试(
retryOnFail) - 否
- 能力
taskhumanworkflow- 标签
humantaskmanagement
说明与限制
- 任务状态:
queued、assigned、claimed、in_progress、completed、rejected、invalidated、expired。本节点创建的任务为queued(有用户负责人时为claimed);后续状态变化在任务收件箱中进行。 - 不暂停也不恢复:之后完成任务不会通知或恢复本次运行。
- 任务的
context.workflow_instance_id和context.trace_id以空值发送:worker 从运行时未设置的字段读取它们,因此任务不会关联到本次运行。 - 非幂等:每次执行都会创建新任务。HTTP 调用不会重试。
- worker 将字段直接放在信封顶层、不使用
data,因此引擎把整个信封(包括port键)作为下一个节点的 payload。 - worker 不设置
ok(示例中显示为true);引擎只按port路由。
已对照编排器代码核实 · 31e874b · 2026-11-26