Skip to content

SocialOps 社交中控 ​

SocialOps 是一个统一 inbox 服务,用于聚合社交消息、IM 渠道、开发协作事件和运维 webhook。当前 MVP 已支持入站聚合、统一 thread、消息存储、筛选查询、控制台查看、内部备注、出站回复队列和按消息计费。

当前状态 ​

后端和控制台 MVP 已可用。第一批 provider 白名单:

Provider状态说明
generic-webhook已可用通用 JSON 事件写入。
telegram已支持归一化写入和定时回复投递需要 telegram-bot Connected Account 和 active SocialOps channel 绑定。
github已支持归一化写入适合 issue、PR、workflow 事件。

Slack、Discord、Teams、X/Twitter、Meta、Instagram、WhatsApp 和 LINE 会通过 Connected Accounts 模块和对应平台 webhook 逐步接入。出站回复会保存为 SocialOps action;暂不支持的 provider 会被标记为 failed,并保留审计错误,而不是静默丢弃。

控制台 ​

创建 socialops 服务实例后,打开:

text
Console > SocialOps

控制台已支持:

  • 查看 SocialOps 服务实例。
  • 按状态、优先级、provider 和关键词筛选 thread。
  • 查看归一化后的消息,不暴露原始 provider payload。
  • 更新 thread 状态、优先级和负责人。
  • 创建出站回复队列,等待 provider adapter 发送。
  • 添加内部备注,保留处理过程。

控制台管理接口使用用户 JWT,并需要 service:read 或 service:manage 权限:

http
GET   /console/socialops/instances
GET   /console/socialops/:alias/inbox
GET   /console/socialops/:alias/threads/:thread_id/messages
POST  /console/socialops/:alias/threads/:thread_id/notes
POST  /console/socialops/:alias/threads/:thread_id/replies
PATCH /console/socialops/:alias/threads/:thread_id

创建内部备注:

json
{
  "text": "已检查 provider 控制台,并指派给 ops。"
}

备注会以 internal SocialOps 消息保存,不会发送到外部平台。

创建出站回复:

json
{
  "text": "我们正在检查这个问题。"
}

回复会以 outbound SocialOps 消息保存,并创建一条 send_reply action,状态为 pending。定时 delivery worker 会消费 pending action,发送已支持的平台,并把 action 标记为 completed 或 failed。

Endpoint ​

http
POST /v1/apps/socialops/:alias/webhook/:provider
GET  /v1/apps/socialops/:alias/inbox
GET  /v1/apps/socialops/:alias/threads
GET  /v1/apps/socialops/:alias/threads/:thread_id/messages
POST /v1/apps/socialops/:alias/threads/:thread_id/replies

所需 scope:

text
socialops:write
socialops:read

写入事件 ​

bash
curl -X POST https://my-gateway.mlc.workers.dev/v1/apps/socialops/support/webhook/generic-webhook \
  -H "X-API-Key: sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "event_id": "evt_1001",
    "thread_id": "incident_42",
    "title": "Incident opened",
    "text": "API latency is high",
    "user": {
      "id": "monitor"
    },
    "labels": ["ops", "urgent"]
  }'

响应:

json
{
  "status": "accepted",
  "provider": "generic-webhook",
  "thread_id": "soth_...",
  "message_id": "somsg_..."
}

查询 Inbox ​

bash
curl "https://my-gateway.mlc.workers.dev/v1/apps/socialops/support/inbox?status=open&priority=high&limit=50" \
  -H "X-API-Key: sk_xxx"

支持的筛选:

Query取值
statusopen、pending、resolved、archived
prioritylow、normal、high、urgent
providergeneric-webhook、telegram、github
q搜索 thread subject 和 AI summary。
page、limit标准分页,limit 最大 100。

创建回复队列 ​

bash
curl -X POST https://my-gateway.mlc.workers.dev/v1/apps/socialops/support/threads/soth_xxx/replies \
  -H "X-API-Key: sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "我们正在检查这个问题。"
  }'

响应:

json
{
  "success": true,
  "data": {
    "message": {
      "direction": "outbound",
      "message_type": "text",
      "text": "我们正在检查这个问题。"
    },
    "action": {
      "action_type": "send_reply",
      "status": "pending"
    }
  }
}

回复投递 ​

定时 worker 会扫描 send_reply action,目前支持 Telegram 投递:

  1. action 会先被 claim 为 processing。
  2. worker 加载 thread、outbound message 和 active SocialOps channel。
  3. channel 必须引用 active 的 telegram-bot Connected Account。
  4. worker 先扣除 SocialOps 回复投递费用。
  5. 调用 Telegram sendMessage,chat id 来自 thread/channel。
  6. 成功后 action 变为 completed,outbound message 保存 Telegram message_id。
  7. 如果 provider 发送失败,会退款,并把 action 标记为 failed。

如果缺少 channel、connected account、余额或 provider adapter,action 会被标记为 failed 并写入审计错误。

数据安全 ​

Inbox 响应默认不会暴露外部平台 thread id。消息响应默认也不会返回原始 provider payload。raw payload 会保留用于审计和后续平台适配,但不应该直接展示在普通客户界面里。

计费 ​

SocialOps 入站消息按已接受的 webhook event 计费。MVP 默认价格为每条入站消息 0.0002 USD。Telegram 回复投递会在定时 worker 真实发送时扣费;provider 发送失败会退款。