TaskFlow 收件箱分流
示例性的 TaskFlow 编排模式:按意图对收件箱消息进行分流,业务消息转 Slack 并等待回复,个人消息立即通知,其余汇总到日终摘要。
它能帮你做什么
先看懂,再决定要不要交给 AI。
本 Skill 提供一个具体的 TaskFlow 编排示例,演示如何在不把运行时变成 DSL 的前提下,对收件箱消息进行分流处理。其核心思路是创建一个托管的 flow,由一个 detached 任务对消息进行分类,分类状态保存在 stateJson 中;当需要等待外部回复(如 Slack 线程)时进入 waiting 状态,并在分类或人工输入完成后恢复 flow。典型的分流规则包括:业务类消息发布到 Slack 并等待回复;个人类消息立即通知所有者;其他消息则累积到日终汇总。文档中给出了建议的 stateJson 结构(businessThreads、personalItems、eodSummary)、Slack 阻塞时的 waitJson 结构,以及一组最小化的运行时调用示例(createManaged、runTask、setWaiting、resume、finish),并附带一个 Lobster 示例文件路径。
怎么交给 AI
在线读取优先,本地安装作为备选。
适合能访问网页的 ChatGPT、Agent 或其他 AI。
请访问 https://skills.dhmip.cn/skills/unknown/taskflow-inbox-triage/SKILL.md,读取并按照该 Skill 完成任务;如当前环境支持本地安装,也可以下载该 Skill。未登录时可使用公共安装文档;登录后可以按不同 AI 分开管理。
请根据 https://skills.dhmip.cn/install/skillhub.md,安装 @unknown/taskflow-inbox-triage。兼容性与要求
安装或使用前,先确认环境是否匹配。
适用客户端
使用要求
- 依赖支持 TaskFlow 编排的运行时/插件环境(示例中提及 api.runtime.tasks.flow)
- 需要提供 tool context (ctx) 以便构造 taskFlow 句柄
- 需要 ACP 运行时及子会话(示例使用 acp 与 agent:main:subagent:classifier)
- 需要能够访问外部通道(例如 Slack)以投递业务消息并接收回复
- 需要支持 stateJson 与 waitJson 的持久化与版本管理(expectedRevision)
⌘技术详情查看完整 SKILL.md 与原始内容⌄
name: taskflow-inbox-triage
description: Example TaskFlow authoring pattern for inbox triage. Use when messages need different treatment based on intent, with some routes notifying immediately, some waiting on outside answers, and others rolling into a later summary.
metadata: { "openclaw": { "emoji": "📥" } }
TaskFlow inbox triage
This is a concrete example of how to think about TaskFlow without turning the core runtime into a DSL.
Goal
Triage inbox items with one owner flow:
- business → post to Slack and wait for reply
- personal → notify the owner now
- everything else → keep for end-of-day summary
Pattern
- Create one flow for the inbox batch.
- Run one detached task to classify new items.
- Persist the routing state in
stateJson. - Move to
waitingonly when an outside reply is required. - Resume the flow when classification or human input completes.
- Finish when the batch has been routed.
Suggested stateJson shape
{
"businessThreads": [],
"personalItems": [],
"eodSummary": []
}
Suggested waitJson when blocked on Slack:
{
"kind": "reply",
"channel": "slack",
"threadKey": "slack:thread-1"
}
Minimal runtime calls
const taskFlow = api.runtime.tasks.flow.fromToolContext(ctx);
const created = taskFlow.createManaged({
controllerId: "my-plugin/inbox-triage",
goal: "triage inbox",
currentStep: "classify",
stateJson: {
businessThreads: [],
personalItems: [],
eodSummary: [],
},
});
const child = taskFlow.runTask({
flowId: created.flowId,
runtime: "acp",
childSessionKey: "agent:main:subagent:classifier",
task: "Classify inbox messages",
status: "running",
startedAt: Date.now(),
lastEventAt: Date.now(),
});
if (!child.created) {
throw new Error(child.reason);
}
const waiting = taskFlow.setWaiting({
flowId: created.flowId,
expectedRevision: created.revision,
currentStep: "await_business_reply",
stateJson: {
businessThreads: ["slack:thread-1"],
personalItems: [],
eodSummary: [],
},
waitJson: {
kind: "reply",
channel: "slack",
threadKey: "slack:thread-1",
},
});
if (!waiting.applied) {
throw new Error(waiting.code);
}
const resumed = taskFlow.resume({
flowId: waiting.flow.flowId,
expectedRevision: waiting.flow.revision,
status: "running",
currentStep: "route_items",
stateJson: waiting.flow.stateJson,
});
if (!resumed.applied) {
throw new Error(resumed.code);
}
taskFlow.finish({
flowId: resumed.flow.flowId,
expectedRevision: resumed.flow.revision,
stateJson: resumed.flow.stateJson,
});
Related example
skills/taskflow/examples/inbox-triage.lobster