Boss Digital Employee Platform — Unified Scheduling and Multi-Channel…

Boss Digital Employee Platform — Unified Scheduling and Multi-Channel Integration Solution

Version: 2.0 | Update Date: 2026-05-29

Core Adjustment: Removed the "Email Center" model. Email is just one of the transmission mediums, essentially equivalent to Feishu/WeCom/Telegram/WorkBuddy.


I. Design Principles

1.1 Channel-Agnostic

The boss does not need to care about which channel a message takes. All business events are distributed via the unified scheduling layer dispatch(), and the platform automatically selects the channel based on priority and configuration:

业务事件 (库存预警/ECR待审/BOM变更/报表就绪)
    │
    ▼
  dispatch()  ← 统一入口,通道无关
    │
    ├── 邮件通道      (SMTP → 老板邮箱 / Coze智能体邮箱)
    ├── 飞书通道      (Webhook → 飞书群/机器人)
    ├── 企微通道      (Webhook → 企业微信群)
    ├── Telegram通道   (Bot API → 私聊/群组)
    └── WorkBuddy通道  (Webhook → AI技能执行)

关键认知:邮箱只是"文档中介"(文档传输载体),不是架构中心。Coze 智能体自带邮箱能力、WorkBuddy 可通过技能收发邮件、飞书也有邮件集成——所有通道本质上都是"把结构化消息投递给老板"。

1.2 Bidirectional Interaction

  • Push (BossAgents → Boss): Business event triggers → dispatch() → multi-channel parallel push
  • Command (Boss → BossAgents): Natural language → any channel access → execute business operation → return result
老板通过任意通道发指令
    │
    ▼
┌─────────────────────────────────────────────┐
│  WorkBuddy Hook   POST /api/workbuddy/hook  │  ← 自然语言→工具执行
│  Coze 回调        POST /api/coze/callback    │  ← 结构化action执行
│  飞书机器人        POST /api/feishu/webhook    │  ← 未来扩展
│  企微机器人        POST /api/wework/webhook    │  ← 未来扩展
└─────────────────────────────────────────────┘
    │
    ▼
  执行引擎 (SCSAI AML / SQLite查询 / LLM推理)
    │
    ▼
  结果 → dispatch() → 推送回老板(任意通道)

1.3 渐进接入

不需要一次配齐所有通道。配一个激活一个:

| Channel | Status | Configuration Requirements |

|------|------|---------|

| Email (SMTP) | Configured | SMTP_* in .env filled, ready to use out-of-the-box |

| WorkBuddy | Configured | Local webhook, implemented |

| Coze Callback | Implemented | /api/coze/callback, can create purchase orders |

| Feishu | To be configured | Fill FEISHU_WEBHOOK in .env |

| WeCom | To be configured | Fill WEWORK_WEBHOOK in .env |

| Telegram | To be configured | Fill TELEGRAM_BOT_TOKEN and CHAT_ID in .env |


II. Core Architecture

2.1 Unified Dispatch Service

File: server/services/unified-dispatch.js

// 核心函数签名
async function dispatch(event) {
  // event = {
  //   type:      'inventory_alert' | 'bom_change' | 'report_ready' | 'task_completed' | 'ecr_pending'
  //   subject:   '库存预警:3项物料低于安全库存'
  //   text:      '纯文本内容'
  //   html:      '<h2>HTML内容</h2>'          // 邮件专用
  //   icon:      '?'
  //   summary:   '摘要'
  //   data:      { items: [...] }             // 结构化数据
  //   channels:  ['email', 'feishu']          // 指定通道,默认全部
  //   priority:  'high' | 'normal' | 'low'
  //   metadata:  {}                            // 透传元数据
  // }
}

6 个便捷方法:

| Method | Event Type | Priority | Typical Trigger |

|------|---------|--------|---------|

| dispatchInventoryAlert(items) | inventory_alert | high | Scheduled inspection detects insufficient inventory |

| dispatchBomChange(changes) | bom_change | normal | BOM engineer modifies BOM structure |

| dispatchEcrPending(ecrInfo) | ecr_pending | high | New ECR submitted awaiting approval |

| dispatchReportReady(reportInfo) | report_ready | low | Digital worker has generated an analysis report |

| dispatchTaskComplete(taskInfo) | task_completed | normal | Digital worker completed a round of execution |

| dispatchNotify(subject, text) | notification | normal | Any custom notification |

Usage example:

const dispatch = require('./server/services/unified-dispatch');

// 库存预警 → 仅推邮件
await dispatch.dispatchInventoryAlert(alertItems, {
  channels: ['email']
});

// ECR待审 → 邮件 + 飞书 + WorkBuddy 三通道
await dispatch.dispatchEcrPending(ecrData, {
  channels: ['email', 'feishu', 'workbuddy']
});

// 报表就绪 → 全通道(默认)
await dispatch.dispatchReportReady(reportInfo);

2.2 五大通道适配器

| 通道 | 适配器函数 | 底层实现 | 配置来源 |

|------|-----------|---------|---------|

| Email | channelEmail() | nodemailer SMTP | .env SMTP_* + config.yaml notify.email |

| Feishu | channelFeishu() | notify.js → Feishu Webhook | config.yaml notify.feishu |

| WeCom | channelWework() | notify.js → WeCom Webhook | config.yaml notify.wework |

| Telegram | channelTelegram() | notify.js → Bot API | config.yaml notify.telegram |

| WorkBuddy | channelWorkbuddy() | HTTP POST → webhook | .env WORKBUDDY_HOOK_URL |

All adapter execution results follow a unified format: { channel: string, ok: boolean, error?: string }

2.3 Dual Channels for Email Notification

The email channel internally contains two sub-channels (not both need to be enabled):

channelEmail()
  ├── boss_agent 子通道  → 推送到 COZE 智能体邮箱 (BOSS_AGENT_EMAIL)
  │                       触发条件: channels 含 'email' 或 'boss_agent'
  │
  └── notify_email 子通道 → 推送到 notify.email.to 收件人列表
                            触发条件: channels 含 'email' 或 'notify_email'
  • boss_agent 子通道:用于让 Coze 智能体收到邮件后自动处理(创建采购单等)
  • notify_email 子通道:用于普通邮件通知(发送给老板/团队成员)

三、双向指令链路

3.1 WorkBuddy 直接对接(已实现)

路由: POST /api/workbuddy/hook

The boss sends natural language via WorkBuddy → BossAgents parses the intent → calls tools → returns results.

Registered tools:

  • query_bom_structure — Query BOM structure
  • check_inventory — Inventory check
  • query_vendors — Supplier query
  • create_purchase_order — Create purchase order
  • get_dashboard — Boss dashboard data

3.2 Coze Callback Integration (Implemented)

Route: POST /api/coze/callback

After the Coze Agent receives an email, it can callback BossAgents to perform operations:

| Action | Description | Implementation Status |

|--------|------|---------|

| ping | Health Check | Implemented |

| create_purchase_order | Create Purchase Order (Write to SCSAI) | Implemented |

| get_inventory_alerts | Query Inventory Alerts | Implemented |

| get_vendor_info | Query Vendor Information | Implemented |

| approve_ecr | Approve ECR | To be implemented |

| query_bom | Query BOM | To be implemented |

3.3 Feishu/WeCom Integration (To be implemented)

In the future, Webhook routes can be registered to connect Feishu bots or WeCom bots, achieving the same natural language → tool execution pipeline.


IV. Configuration System

4.1 Configuration Priority

环境变量 (.env)  >  config.yaml  >  代码默认值

4.2 邮件配置(已就绪)

.env 文件:

SMTP_HOST=smtp.sina.com
SMTP_PORT=465
SMTP_SECURE=true
SMTP_USER=tuan_zhang@sina.com
SMTP_PASS=******
SMTP_FROM_NAME=WorkBuddy
SMTP_FROM=tuan_zhang@sina.com
NOTIFICATION_EMAIL=tuan_zhang@sina.com   # 收件人

config-loader 自动映射到 config.notify.email,并设 enabled = true。

4.3 Adding a new channel requires only two steps

Take Feishu as an example:

Step 1: Add to .env

FEISHU_WEBHOOK=https://open.feishu.cn/open-apis/bot/v2/hook/xxx

Step 2: config.yaml 添加(或通过环境变量覆盖)

notify:
  feishu:
    enabled: true
    webhook_url: https://open.feishu.cn/open-apis/bot/v2/hook/xxx

统一调度层自动识别并激活,无需改代码。


V. Event-Triggered Scenarios

5.1 Automatic Triggering (Digital Employee Patrol)

定时任务 (node-cron)
  │
  ├── 库存巡检 (每小时) → 发现缺料 → dispatchInventoryAlert()
  ├── ECR 扫描 (15分钟) → 待审批ECR → dispatchEcrPending()
  ├── 供应商评分 (每天) → 质量下降 → dispatchNotify()
  └── BOM 变更监听       → 结构变更 → dispatchBomChange()

5.2 手动触发(老板指令)

老板 → WorkBuddy/Coze/飞书 → 自然语言
  │
  ├── "查一下最近的库存预警"  → getInventoryAlerts → 返回数据
  ├── "帮我创建采购单给XX供应商" → createPurchaseOrder → 返回PO号
  ├── "ECR-001 通过审批"      → approveECR → 返回审批结果
  └── "把这份报告发给我"      → dispatchReportReady() → 推送到所有通道

5.3 闭环场景(推送→指令→执行→推送)

库存巡检发现缺料
  → dispatchInventoryAlert() 推送到老板邮箱
  → 老板回复 "给XX供应商创建采购单"
  → Coze/WorkBuddy 识别指令
  → POST /api/coze/callback { action: 'create_purchase_order', ... }
  → SCSAI 创建采购单
  → dispatchTaskComplete() 通知老板 "采购单 PO-XXX 已创建"

六、当前实现状态

6.1 已完成

| 模块 | 文件 | 说明 |

|------|------|------|

| Unified Dispatch Service | server/services/unified-dispatch.js | dispatch() + 6 convenience methods + 5 channel adapters |

| Email Service | server/services/email-service.js | nodemailer SMTP, sendToBossAgent / sendEmail |

| Generic Push | notify.js | Underlying implementations for Feishu/WeCom/Telegram/Email 4 channels |

| Coze Callback | server/services/coze-callback-service.js | 4 actions implemented |

| WorkBuddy Integration | server.js (routes) | hook + tools + execute 3 APIs |

| Push Routing | server.js | /api/dispatch POST + /api/dispatch/history GET |

| Push History | dispatch_history table | boss_analytics.db records each push result |

| Configuration Loading | config-loader.js | .env → config mapping, SMTP auto-enable |

| Inventory Alert Integration | server/agents/inventory-alert-agent.js | Now uses dispatch.dispatchInventoryAlert() |

6.2 To Be Completed

ModuleDescriptionPriority
ECR Digital Worker IntegrationCall dispatchEcrPending() after ECR review completesP1
BOM Change Monitoring IntegrationCall dispatchBomChange() on BOM changeP1
Cost Optimization Report IntegrationCall dispatchReportReady() after report generationP2
Feishu Webhook RoutingPOST /api/feishu/webhook natural language → executionP2
WeChat Work Webhook RoutingPOST /api/wework/webhook natural language → executionP2
Coze Action Extensionapprove_ecr, query_bom, etc.P2
Frontend Display of Push HistoryDashboard display of dispatch_history for managementP2
Channel Priority StrategyIntelligent channel selection based on priority and timezoneP3

VII. Comparison with the Legacy Solution

DimensionLegacy Solution (Email Hub)New Solution (Channel-Agnostic)
Architectural CenterEmail (Coze Agent Mailbox)Unified Dispatch Layer dispatch()
Email RoleHub, all messages relayed via emailOne channel among equals, equivalent to others
Adding New ChannelsRequires modifications around the email hubOnly requires adding a channel adapter + configuration
Integration MethodMust configure emailAny channel can be integrated independently
Management ExperienceLimited to viewing emailsChoice of Feishu/WeCom/Telegram/Email/WB, etc.
Closed-loop WorkflowEmail→Coze→Callback→EmailAny channel in → Execution → Any channel out

VIII. API Quick Reference

Push (Outbound)

POST /api/dispatch
Body: { type, subject, text, channels, data, priority }
Response: { success, results: [{ channel, ok }], dispatched_at }

GET /api/dispatch/history?limit=20
Response: [{ event_type, subject, channels, success_count, dispatched_at }]

Command (Inbound)

POST /api/workbuddy/hook
Body: { message: "自然语言指令" }
Response: { reply, data }

POST /api/coze/callback
Body: { action: "create_purchase_order", data: {...} }
Response: { success, data: { po_no } }

GET /api/workbuddy/tools
Response: [{ name, description, parameters }]
← 返回案例列表

Try 左帮右臂 Industrial Agent — your digital workforce

Available as a WeChat mini program, web app (ylxt.chat) and desktop client. Start from whichever fits your workflow.

🌐 Web App 💻 Desktop Download 📞 Call 189-8606-6876
WeChat mini program QR
Scan for the WeChat mini program
Share:
🤖 Try Now →
🤖
🎁