Chuyển đến nội dung

Workflow

client.workflows quản lý flow engine của Imbrace: tạo và kích hoạt các luồng tự động hóa, xem lịch sử chạy, tổ chức với folders, quản lý app connections và MCP servers, và truy cập workflow tables.

Để xem hướng dẫn chi tiết, tham khảo Workflows trong SDK guide.


Schema

Flow

FieldTypeMô tả
idstringID duy nhất của flow
createdstringISO 8601 thời gian tạo
updatedstringISO 8601 thời gian cập nhật
projectIdstringDự án sở hữu flow này
externalIdstringĐịnh danh bên ngoài tùy chọn
status"ENABLED" | "DISABLED"Flow có đang hoạt động không
operationStatusstringTrạng thái thao tác hiện tại
versionFlowVersionĐối tượng phiên bản đang hoạt động

FlowVersion

FieldTypeMô tả
idstringID duy nhất của phiên bản
createdstringISO 8601 thời gian tạo
updatedstringISO 8601 thời gian cập nhật
flowIdstringFlow của phiên bản này
displayNamestringTên flow dễ đọc
triggerobjectCấu hình trigger
stepsobject?Cấu hình bước tùy chọn
validboolean?Phiên bản có hợp lệ không

FlowRun

FieldTypeMô tả
idstringID duy nhất của run
createdstringISO 8601 thời gian tạo
updatedstringISO 8601 thời gian cập nhật
projectIdstringID dự án
flowIdstringFlow đã được thực thi
flowVersionIdstringPhiên bản cụ thể đã chạy
status"RUNNING" | "SUCCEEDED" | "FAILED" | "TIMEOUT" | "PAUSED" | "STOPPED"Kết quả chạy
environment"PRODUCTION" | "TESTING"Môi trường thực thi
startTimestring?Thời điểm bắt đầu chạy
finishTimestring?Thời điểm kết thúc chạy
failParentOnFailurebooleanLỗi có lan truyền lên flow cha không
tagsstring[]?Thẻ gắn vào run này

AppConnection

FieldTypeMô tả
idstringID duy nhất của kết nối
createdstringISO 8601 thời gian tạo
updatedstringISO 8601 thời gian cập nhật
externalIdstringĐịnh danh bên ngoài
displayNamestringTên dễ đọc
pieceNamestringPiece (tích hợp) mà kết nối này dành cho
projectIdstringID dự án
type"SECRET_TEXT" | "OAUTH2" | "CLOUD_OAUTH2" | "PLATFORM_OAUTH2" | "BASIC_AUTH" | "CUSTOM_AUTH"Loại xác thực kết nối

McpServer

FieldTypeMô tả
idstringID duy nhất của MCP server
createdstringISO 8601 thời gian tạo
updatedstringISO 8601 thời gian cập nhật
projectIdstringID dự án
namestring?Tên server

Methods

Flows

MethodTypeScriptPythonMô tả
List flowslistFlowslist_flowsDanh sách flows có phân trang
Get flowgetFlowget_flowLấy một flow theo ID
Create flowcreateFlowcreate_flowTạo flow mới
Delete flowdeleteFlowdelete_flowXóa flow
Apply flow operationapplyFlowOperationapply_flow_operationÁp dụng thao tác (vd: publish, enable) cho flow
Trigger flowtriggerFlowtrigger_flowKích hoạt flow bất đồng bộ
Trigger flow synctriggerFlowSynctrigger_flow_syncKích hoạt flow và chờ kết quả

Flow Runs

MethodTypeScriptPythonMô tả
List runslistRunslist_runsDanh sách lịch sử chạy
Get rungetRunget_runLấy một run theo ID

Folders

MethodTypeScriptPythonMô tả
List folderslistFolderslist_foldersDanh sách thư mục flow
Get foldergetFolderget_folderLấy thư mục theo ID
Create foldercreateFoldercreate_folderTạo thư mục
Update folderupdateFolderupdate_folderĐổi tên thư mục
Delete folderdeleteFolderdelete_folderXóa thư mục

App Connections

MethodTypeScriptPythonMô tả
List connectionslistConnectionslist_connectionsDanh sách app connections
Get connectiongetConnectionget_connectionLấy kết nối theo ID
Upsert connectionupsertConnectionupsert_connectionTạo hoặc cập nhật kết nối
Delete connectiondeleteConnectiondelete_connectionXóa kết nối

MCP Servers

MethodTypeScriptPythonMô tả
List MCP serverslistMcpServerslist_mcp_serversDanh sách MCP servers
Get MCP servergetMcpServerget_mcp_serverLấy server theo ID
Create MCP servercreateMcpServercreate_mcp_serverĐăng ký MCP server mới
Delete MCP serverdeleteMcpServerdelete_mcp_serverXóa server
Rotate tokenrotateMcpTokenrotate_mcp_tokenXoay token xác thực của server

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

Kích hoạt flow bất đồng bộ với payload tùy chọn.

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

Tạo hoặc cập nhật app connection (vd: API key cho dịch vụ bên thứ ba).

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",
});