# 陪练

# 新增陪练场景

事件类型:ai_train/scenario/add

# 回调示例

{
  "nonce": "8b0a3e34-1a54-4c8f-9a1e-6f2b8d3c5a11",
  "timestamp": 1760425000,
  "sign": "3f0a1c9d7b5e2a4c8d6f0b2e4a6c8d0e2f4a6b8c",
  "action": "ai_train/scenario/add",
  "attributes": {
    "scenario_id": "3eabf99f9a2047aebdd6d104be3977d7",
    "title": "商品导购",
    "description": "为客户介绍商品,让客户了解商品的优势。",
    "category_id": "5939f99e9f4211eca5914ac6b68baxxx",
    "privilege_type": 1,
    "privileges": [
      {
        "type": "department",
        "id": "1"
      },
      {
        "type": "staff",
        "id": "zhangsan"
      },
      {
        "type": "contacttag",
        "id": "f31993b6a29511ecabb6e6ac26dccxxx"
      },
      {
        "type": "team",
        "id": "30fff19ebae611ecad5bee5022d7cxxx"
      }
    ],
    "team_id": "30fff19ebae611ecad5bee5022d7cxxx",
    "created_at": "2026-10-27 10:12:31"
  },
  "operator": "lisi",
  "operator_info": {
    "name": "lisi"
  }
}
# 参数说明:
参数 说明
nonce 用户触发的事件临时码
timestamp 用户触发的事件时间戳
sign 用户触发的事件签名
action 用户触发的事件行为类型
attributes.scenario_id 陪练场景id
attributes.title 陪练场景名称
attributes.description 陪练场景简介
attributes.category_id 陪练场景关联的分类id
attributes.privilege_type 学员范围的公开情况:0 公开,1 部分人可见(非公开),2 仅创建者可见
attributes.privileges 学员范围明细(成员、部门、标签、K吧),privilege_type 为 0 时为空数组
attributes.privileges.type 范围类型:staff 成员,department 部门,contacttag 标签,team K吧
attributes.privileges.id 范围对应的id,type 为 staff 时为成员的StaffID,其余类型为对应的实体id
attributes.team_id 陪练场景关联的K吧id
attributes.created_at 陪练场景的创建时间
operator 触发者StaffID
operator_info.name 触发者姓名

# 编辑陪练场景

事件类型:ai_train/scenario/edit

编辑陪练场景(含调整学员范围、批量调整场景所属K吧、结束陪练)后触发。

# 回调示例

{
  "nonce": "c1e2b7a4-93d5-4f6a-b0c8-2d7e9a1f4b33",
  "timestamp": 1760425300,
  "sign": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b",
  "action": "ai_train/scenario/edit",
  "attributes": {
    "scenario_id": "3eabf99f9a2047aebdd6d104be3977d7",
    "title": "商品导购(已调整学员范围)",
    "description": "为客户介绍商品,让客户了解商品的优势。",
    "category_id": "5939f99e9f4211eca5914ac6b68baxxx",
    "privilege_type": 1,
    "privileges": [
      {
        "type": "staff",
        "id": "zhangsan"
      },
      {
        "type": "staff",
        "id": "lisi"
      }
    ],
    "team_id": "30fff19ebae611ecad5bee5022d7cxxx",
    "updated_at": "2026-10-27 10:35:07"
  },
  "operator": "lisi",
  "operator_info": {
    "name": "lisi"
  }
}
# 参数说明:
参数 说明
nonce 用户触发的事件临时码
timestamp 用户触发的事件时间戳
sign 用户触发的事件签名
action 用户触发的事件行为类型
attributes.scenario_id 陪练场景id
attributes.title 陪练场景名称
attributes.description 陪练场景简介
attributes.category_id 陪练场景关联的分类id
attributes.privilege_type 学员范围的公开情况:0 公开,1 部分人可见(非公开),2 仅创建者可见
attributes.privileges 学员范围明细(成员、部门、标签、K吧),调整学员范围后为调整后的全量范围,非增量
attributes.privileges.type 范围类型:staff 成员,department 部门,contacttag 标签,team K吧
attributes.privileges.id 范围对应的id,type 为 staff 时为成员的StaffID,其余类型为对应的实体id
attributes.team_id 陪练场景关联的K吧id
attributes.updated_at 陪练场景的更新时间
operator 触发者StaffID
operator_info.name 触发者姓名

# 删除陪练场景

事件类型:ai_train/scenario/delete

# 回调示例

{
  "nonce": "5d4c3b2a-1908-47f6-8e5d-3c2b1a0f9e8d",
  "timestamp": 1760425600,
  "sign": "1f2e3d4c5b6a7988970a1b2c3d4e5f60718293a",
  "action": "ai_train/scenario/delete",
  "attributes": {
    "scenario_id": "3eabf99f9a2047aebdd6d104be3977d7",
    "title": "商品导购",
    "description": "为客户介绍商品,让客户了解商品的优势。",
    "category_id": "5939f99e9f4211eca5914ac6b68baxxx",
    "privilege_type": 1,
    "privileges": [
      {
        "type": "staff",
        "id": "zhangsan"
      }
    ],
    "team_id": "30fff19ebae611ecad5bee5022d7cxxx",
    "deleted_at": "2026-10-27 10:47:52"
  },
  "operator": "lisi",
  "operator_info": {
    "name": "lisi"
  }
}
# 参数说明:
参数 说明
nonce 用户触发的事件临时码
timestamp 用户触发的事件时间戳
sign 用户触发的事件签名
action 用户触发的事件行为类型
attributes.scenario_id 删除的陪练场景id
attributes.title 陪练场景名称
attributes.description 陪练场景简介
attributes.category_id 陪练场景关联的分类id
attributes.privilege_type 删除前学员范围的公开情况
attributes.privileges 删除前学员范围明细
attributes.team_id 陪练场景关联的K吧id
attributes.deleted_at 陪练场景的删除时间
operator 触发者StaffID
operator_info.name 触发者姓名

# 注意事项

# 学员范围(privileges)没有独立的回调事件

陪练没有"学员范围调整"这一独立事件类型,场景的学员范围随 ai_train/scenario/add、ai_train/scenario/edit、ai_train/scenario/delete 事件一同下发,体现在 attributes.privilege_type 与 attributes.privileges 字段上。

因此接收方无法通过 action 区分本次编辑是"改了场景名称/简介"还是"改了学员范围",需要自行比对 privileges 的变化来判断范围是否发生调整。

# 时间字段随事件类型变化

created_at、updated_at、deleted_at 三个时间字段按事件类型分别下发,不会同时出现:

事件类型 下发的时间字段
ai_train/scenario/add created_at
ai_train/scenario/edit updated_at
ai_train/scenario/delete deleted_at

# edit 事件的触发场景

除编辑陪练场景外,以下操作同样会下发 ai_train/scenario/edit:

  • 批量调整陪练场景所属K吧(每个场景各下发一次)
  • 结束陪练(手动结束或到达练习截止时间)

# 场景归属项目时的学员范围

陪练场景添加到项目下时,学员范围跟随所属项目继承,不再单独维护场景自身的范围,此时回调中的 privileges 为空数组。