跳转到内容

Workflow

client.workflows 管理 Imbrace 流程引擎:创建和触发自动化流程、查看运行历史、使用文件夹组织、管理应用连接和 MCP 服务器,以及访问工作流表格。

如需逐步指南,请参阅 SDK 指南中的 Workflows


Schema

Flow

FieldType说明
idstring唯一流程 ID
createdstringISO 8601 创建时间戳
updatedstringISO 8601 更新时间戳
projectIdstring所属项目
externalIdstring可选外部标识符
status"ENABLED" | "DISABLED"流程是否启用
operationStatusstring当前操作状态
versionFlowVersion启用中的版本对象

FlowVersion

FieldType说明
idstring唯一版本 ID
createdstringISO 8601 创建时间戳
updatedstringISO 8601 更新时间戳
flowIdstring此版本所属的流程
displayNamestring人类可读的流程名称
triggerobject触发器配置
stepsobject?可选步骤配置
validboolean?版本是否有效

FlowRun

FieldType说明
idstring唯一运行 ID
createdstringISO 8601 创建时间戳
updatedstringISO 8601 更新时间戳
projectIdstring项目 ID
flowIdstring已执行的流程
flowVersionIdstring运行的特定版本
status"RUNNING" | "SUCCEEDED" | "FAILED" | "TIMEOUT" | "PAUSED" | "STOPPED"运行结果
environment"PRODUCTION" | "TESTING"执行环境
startTimestring?运行开始时间
finishTimestring?运行结束时间
failParentOnFailureboolean失败是否传播到父流程
tagsstring[]?附加到此运行的标签

AppConnection

FieldType说明
idstring唯一连接 ID
createdstringISO 8601 创建时间戳
updatedstringISO 8601 更新时间戳
externalIdstring外部标识符
displayNamestring人类可读名称
pieceNamestring此连接所属的 piece(集成)
projectIdstring项目 ID
type"SECRET_TEXT" | "OAUTH2" | "CLOUD_OAUTH2" | "PLATFORM_OAUTH2" | "BASIC_AUTH" | "CUSTOM_AUTH"连接认证类型

McpServer

FieldType说明
idstring唯一 MCP 服务器 ID
createdstringISO 8601 创建时间戳
updatedstringISO 8601 更新时间戳
projectIdstring项目 ID
namestring?服务器名称

Methods

Flows

MethodTypeScriptPython说明
List flowslistFlowslist_flows分页的流程列表
Get flowgetFlowget_flow按 ID 获取单个流程
Create flowcreateFlowcreate_flow创建新流程
Delete flowdeleteFlowdelete_flow删除流程
Apply flow operationapplyFlowOperationapply_flow_operation对流程应用操作(例如发布、启用)
Trigger flowtriggerFlowtrigger_flow异步触发流程
Trigger flow synctriggerFlowSynctrigger_flow_sync触发流程并等待结果

Flow Runs

MethodTypeScriptPython说明
List runslistRunslist_runs列出运行历史
Get rungetRunget_run按 ID 获取单个运行

Folders

MethodTypeScriptPython说明
List folderslistFolderslist_folders列出流程文件夹
Get foldergetFolderget_folder按 ID 获取文件夹
Create foldercreateFoldercreate_folder创建文件夹
Update folderupdateFolderupdate_folder重命名文件夹
Delete folderdeleteFolderdelete_folder删除文件夹

App Connections

MethodTypeScriptPython说明
List connectionslistConnectionslist_connections列出应用连接
Get connectiongetConnectionget_connection按 ID 获取连接
Upsert connectionupsertConnectionupsert_connection创建或更新连接
Delete connectiondeleteConnectiondelete_connection移除连接

MCP Servers

MethodTypeScriptPython说明
List MCP serverslistMcpServerslist_mcp_servers列出 MCP 服务器
Get MCP servergetMcpServerget_mcp_server按 ID 获取服务器
Create MCP servercreateMcpServercreate_mcp_server注册新的 MCP 服务器
Delete MCP serverdeleteMcpServerdelete_mcp_server移除服务器
Rotate tokenrotateMcpTokenrotate_mcp_token轮换服务器的认证令牌

listFlows / list_flows

const page = await client.workflows.listFlows({
limit: 10,
status: "ENABLED",
folderId: "folder_id",
});
for (const flow of page.data) {
console.log(flow.id, flow.version?.displayName);
}

createFlow / create_flow

const flow = await client.workflows.createFlow({
displayName: "New Lead Notification",
projectId: "project_id",
});
console.log(flow.id);

triggerFlow / trigger_flow

使用可选负载异步触发流程。

await client.workflows.triggerFlow("flow_id", {
contact_id: "contact_123",
event: "lead_created",
});

listRuns / list_runs

const page = await client.workflows.listRuns({
flowId: "flow_id",
status: "FAILED",
limit: 20,
});

upsertConnection / upsert_connection

创建或更新应用连接(例如第三方服务的 API 密钥)。

const conn = await client.workflows.upsertConnection({
displayName: "Slack Workspace",
pieceName: "slack",
projectId: "project_id",
type: "SECRET_TEXT",
value: { api_key: "xoxb-..." },
});

createMcpServer / create_mcp_server

const server = await client.workflows.createMcpServer({
name: "My MCP Server",
projectId: "project_id",
});