979 lines
19 KiB
Markdown
979 lines
19 KiB
Markdown
|
||
|
||
|
||
|
||
# 1. 登录注册类
|
||
|
||
## 1.1 发送验证码
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"user_name":"civet148", //账户名
|
||
"email":"civet148@126.com", //邮箱地址
|
||
"action_type":0, //操作类型: 0=用户注册 1=重置密码
|
||
"language":"en" //语言: en=英文 zh-CN=简体中文
|
||
}
|
||
```
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 1.2 商户注册
|
||
|
||
**请求JSON**
|
||
|
||
```sh
|
||
{
|
||
"user_name":"civet148@126.com",
|
||
"password":"e10adc3949ba59abbe56e057f20f883e",
|
||
"email":"civet148@126.com",
|
||
"reg_code": "888888"
|
||
}
|
||
```
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 1.3 商户登录
|
||
|
||
|
||
**请求JSON**
|
||
|
||
```sh
|
||
{
|
||
"user_name":"civet148@126.com",
|
||
"password":"e10adc3949ba59abbe56e057f20f883e"
|
||
}
|
||
```
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
## 1.4 商户退出
|
||
|
||
|
||
**请求JSON**
|
||
|
||
```sh
|
||
{
|
||
}
|
||
```
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
# 2. AI员工类接口
|
||
|
||
## 2.1 创建员工
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/create/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"name":"我的AI员工1号", //员工名称(必填)
|
||
"org_name":"销售部", //组织名称(必填)
|
||
"tone":"friendly and sincere", //语气:friendly and sincere(友好且真诚), professional and cautious(专业且稳重), clear and direct(清晰且直接)
|
||
"output_length":"normal-length", //回复长度:detailed(详细), normal-length(正常长度), concise(简洁)
|
||
"language_mode":"written", //语言模式:written(书面),spoken(口语)
|
||
"language_response":"Chinese", //回复语言:Chinese、English
|
||
"description":"销冠的潜质", //员工描述
|
||
"greetings":"您好,我是1号员工,很高兴为您服务!", //问候语
|
||
"avatar_url":"https://www.pic.com/avatar001.jpg" //头像URL
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"id": 1001
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 2.2 员工列表
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/list/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 0, //按员工ID查询
|
||
"name": "", //按员工名称查询
|
||
"serial_no": "", //按员工序列号查询
|
||
"page_no": 0,
|
||
"page_size": 20
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"list": [
|
||
{
|
||
"id":1, //员工ID
|
||
"serial_no":"123456", //员工序列号
|
||
"customer_id":1, //归属客户ID
|
||
"name":"AI001", //员工名称
|
||
"org_name":"SellDepartment", //组织名称
|
||
"tone":"", //语气(亲切/严肃/专业等等)
|
||
"output_length":"", //回复长度(短/中/长等等)
|
||
"language_mode":"written", //语言模式:written(书面),spoken(口语)
|
||
"language_response":"Chinese", //回复语言:Chinese、English
|
||
"description":"", //描述
|
||
"trial_time":"", //试用结束时间
|
||
"expiring_time":"", //有效期截止时间
|
||
"state":0, //状态(0=未激活 1=正常 2=接近过期 3=已过期)
|
||
"edit_user":"", //最后编辑人
|
||
"is_frozen": false, //是否已冻结
|
||
"api_key": "", //API key (系统自定生成,不能编辑)
|
||
"secret_key": "", //Secret key (系统自定生成,不能编辑)
|
||
"chat_url":"", //智能员工URL
|
||
"avatar_url":"", //智能员工头像
|
||
"greetings":"您好,我是1号员工,很高兴为您服务!", //问候语
|
||
"repo_name":"我的资料库", //知识库名称
|
||
"repo_descr":"大堂经理培训资料库", //知识库描述
|
||
"is_deleted": false, //是否已删除(0=未删除 1=已删除)
|
||
"created_time":"2024-04-23 10:32:30", //创建时间
|
||
"updated_time":"2024-04-23 10:32:30" //更新时间
|
||
}
|
||
]
|
||
}
|
||
}
|
||
|
||
|
||
```
|
||
|
||
|
||
## 2.3 编辑员工
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/edit/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1, //员工ID (必填)
|
||
"serial_no": "123456", //员工序列号
|
||
"name": "AI001", //员工名称
|
||
"org_name": "SellDepartment", //组织名称
|
||
"tone":"friendly and sincere", //语气:friendly and sincere(友好且真诚), professional and cautious(专业且稳重), clear and direct(清晰且直接)
|
||
"output_length":"normal-length", //回复长度:detailed(详细), normal-length(正常长度), concise(简洁)
|
||
"language_mode":"written", //语言模式:written(书面),spoken(口语)
|
||
"language_response":"Chinese", //回复语言:Chinese、English
|
||
"description": "", //描述
|
||
"is_frozen": false, //是否已冻结
|
||
"chat_url": "", //智能员工URL
|
||
"avatar_url": "", //智能员工头像
|
||
"greetings":"您好,我是1号员工,很高兴为您服务!", //问候语
|
||
"repo_name":"我的资料库", //知识库名称
|
||
"repo_descr":"大堂经理培训资料库" //知识库描述
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
## 2.4 删除员工
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/delete/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1 //员工ID (必填)
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 2.5 冻结/解冻员工
|
||
|
||
Token: required
|
||
|
||
冻结:POST /api/v1/customer/frozen/staff
|
||
解冻:POST /api/v1/customer/unfrozen/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1 //员工ID
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
|
||
## 2.6 套餐支付
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/pay/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1, //需要支付的员工ID
|
||
"production_id": 2, //支付套餐ID
|
||
"pay_type":"alipay" //支付方式(wxpay=微信支付 alipay=支付宝 stripe=Stripe支付)
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"pay_type": "alipay", //支付方式
|
||
"trade_no": "NO202404251606089389209168633" //支付订单号
|
||
"pay_url": "https://qr.alipay.com/bax02518wkpb3p3e9fro3071" //支付链接(自行用插件转为二维码)
|
||
}
|
||
}
|
||
```
|
||
|
||
## 2.7 查询支付状态
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/query/trade
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"trade_no": "NO202404251606089389209168633" //支付订单号
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"state": 0, //支付状态(0=等待付款 1=已完成付款 2=付款超时关闭 3=已退款 4=已结束[不可退款] 5=支付平台异常)
|
||
"message": "Success" //订单交易状态信息
|
||
}
|
||
}
|
||
```
|
||
|
||
## 2.8 上传资料
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/upload/file
|
||
|
||
**请求Form-data**
|
||
|
||
```json
|
||
file_name => QQ.jpg
|
||
file_data => 图片二进制数据
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"file_name": "QQ.jpg",
|
||
"file_path": "1713856350987496426_QQ.jpg"
|
||
"file_size": 1034123,
|
||
"file_url": "http://116.213.39.234:8084/assets/files/1713856350987496426_QQ.jpg"
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 2.9 客服聊天
|
||
|
||
[**WEBSOCKET**]
|
||
|
||
ws://116.213.39.234:8084/ws
|
||
|
||
以AI员工的api key**和**secret key**作为用户名密码采用**BasicAuth**方式鉴权
|
||
|
||
## 2.10 培训资料列表
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/list/doc
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"staff_id": 1, //员工ID
|
||
"page_no": 0,
|
||
"page_size": 20
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"list":[
|
||
{
|
||
"id": 1, //文档ID
|
||
"file_name":"文档1.docx", //原始文件名
|
||
"file_path":"2141242323_文档1.docx", //文件存储相对路径
|
||
"file_size": 1412423, //文件大小(字节)
|
||
"file_url":"", //文件访问URL
|
||
"created_time":"2024-04-26 18:23:33", //创建时间
|
||
"updated_time":"2024-04-26 18:23:33" //更新时间
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
## 2.11 更新培训资料
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/update/doc
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"staff_id": 1, //员工ID
|
||
"docs":[
|
||
{
|
||
"file_name":"文档1.docx", //原始文件名
|
||
"file_path":"2141242323_文档1.docx", //实际文件存储路径
|
||
"file_size": 1412423, //文件大小(字节)
|
||
"file_url": "" //文件访问URL
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": { }
|
||
}
|
||
```
|
||
|
||
|
||
## 2.12 删除培训资料
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/delete/doc
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"staff_id": 1, //员工ID
|
||
"ids": [1,2,3] //要删除的文档ID列表
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": { }
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 2.13 同步培训资料
|
||
|
||
触发同步消息给到AI服务器,更新知识库
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/sync/doc
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"staff_id": 1 //员工ID
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {}
|
||
}
|
||
```
|
||
|
||
## 2.14 序列号查询员工
|
||
|
||
Token: no
|
||
|
||
POST /api/v1/customer/query/staff
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"serial_no": "safasdfsdfs" //按员工序列号查询
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"list": [
|
||
{
|
||
"id":1, //自增ID
|
||
"serial_no":"123456", //员工序列号
|
||
"customer_id":1, //归属客户ID
|
||
"name":"AI001", //员工名称
|
||
"org_name":"SellDepartment", //组织名称
|
||
"tone":"", //语气(亲切/严肃/专业等等)
|
||
"output_length":"", //回复长度(短/中/长等等)
|
||
"language_mode":"written", //语言模式:written(书面),spoken(口语)
|
||
"language_response":"Chinese", //回复语言:Chinese、English
|
||
"description":"", //描述
|
||
"trial_time":"", //试用结束时间
|
||
"expiring_time":"", //有效期截止时间
|
||
"state":0, //状态(0=未激活 1=正常 2=接近过期 3=已过期)
|
||
"edit_user":"", //最后编辑人
|
||
"is_frozen": false, //是否已冻结
|
||
"api_key": "", //API key (系统自定生成,不能编辑)
|
||
"secret_key": "", //Secret key (系统自定生成,不能编辑)
|
||
"chat_url":"", //智能员工URL
|
||
"avatar_url":"", //智能员工头像
|
||
"greetings":"您好,我是1号员工,很高兴为您服务!", //问候语
|
||
"repo_name":"我的资料库", //知识库名称
|
||
"repo_descr":"大堂经理培训资料库", //知识库描述
|
||
"is_deleted": false, //是否已删除(0=未删除 1=已删除)
|
||
"created_time":"2024-04-23 10:32:30", //创建时间
|
||
"updated_time":"2024-04-23 10:32:30" //更新时间
|
||
}
|
||
]
|
||
}
|
||
}
|
||
|
||
```
|
||
|
||
|
||
|
||
## 2.15 账单列表
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/list/billing
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 0, //按账单ID查询
|
||
"page_no": 0,
|
||
"page_size": 20
|
||
}
|
||
```
|
||
|
||
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"list": [
|
||
{
|
||
"id":1, //自增ID
|
||
"customer_id": 1, //客户ID
|
||
"staff_id": 2, //员工ID
|
||
"pay_type":"alipay", //支付方式(wxpay=微信 alipay=支付宝 stripe=Stripe支付)
|
||
"trade_no":"NO20240510150293234234234", //商家交易订单号(商家系统唯一ID)
|
||
"transaction_id":"2024051015029323423", //支付平台唯一交易ID
|
||
"customer_email":"", //客户邮箱地址(Stripe支付必填)
|
||
"prod_id": 1, //产品ID
|
||
"prod_no": "", //产品序列号
|
||
"prod_name":"标准版包月¥199", //产品名称
|
||
"prod_price":"199.00", //产品价格
|
||
"currency":"CNY", //单位(CNY/USD...)
|
||
"pay_amount":"199.00", //支付金额(单位: 元)
|
||
"refund_amount":"0", //退款金额(单位: 元)
|
||
"state": 1, //支付状态(0=等待付款 1=已完成付款 2=付款超时关闭 3=已退款 4=已结束[不可退款] 5=支付平台异常)
|
||
"created_time":"2024-05-10 15:33:03", //创建时间
|
||
"updated_time":"2024-05-10 15:34:24", //更新时间
|
||
"pay_url":"", //支付链接
|
||
"extra_data":null, //附带数据(JSON)
|
||
"message":"Success", //支付交易信息
|
||
"payer":"civet148@163.com" //支付人信息
|
||
}
|
||
]
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
# 3. 产品类接口
|
||
|
||
## 3.1 创建产品 (管理端)
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/admin/create/production
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"name":"标准版包月套餐" //产品名称
|
||
"price":"199", //产品价格(单位: 元)
|
||
"currency":"CNY", //单位(CNY/USD...)
|
||
"state": 0, //状态(0=待上架 1=已上架 2=已下架)
|
||
"language":"zh-CN", //区域语言(中国=zh-CN 英美=en)
|
||
"description":"标准版包月套餐,中小企业福利", //产品描述
|
||
"trial_days": 7, //产品试用期(单位: 天)
|
||
"expiring_days":31 //产品有效期(单位: 天)
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"id": 10
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
## 3.2 产品列表 (商户和管理端)
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/customer/list/production (**商户端**)
|
||
|
||
POST /api/v1/admin/list/production (**管理端**)
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 0, //按产品ID查询
|
||
"name": "", //按产品名称查询
|
||
"serial_no": "", //按产品序列号查询
|
||
"page_no": 0,
|
||
"page_size": 20
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
"list": [
|
||
{
|
||
"id": 1, //产品ID
|
||
"name":"标准版包月套餐" //产品名称
|
||
"price":"199", //产品价格(单位: 元)
|
||
"currency":"CNY", //单位(CNY/USD...)
|
||
"state": 0, //状态(0=待上架 1=已上架 2=已下架)
|
||
"language":"zh-CN", //区域语言(中国=zh-CN 英美=en)
|
||
"description":"标准版包月套餐,中小企业福利", //产品描述
|
||
"trial_days": 7, //产品试用期(单位: 天)
|
||
"expiring_days":31 //产品有效期(单位: 天)
|
||
"serial_no": "asfsafasfs" //产品序列号(唯一)
|
||
"is_deleted": false, //是否已删除(0=未删除 1=已删除)
|
||
"create_user": "admin", //创建人
|
||
"edit_user": "admin", //编辑人
|
||
"created_time":"2024-04-23 10:32:30", //创建时间
|
||
"updated_time":"2024-04-23 10:32:30" //更新时间
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
## 3.3 编辑产品 (管理端)
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/admin/edit/production
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1, //产品ID (必填)
|
||
"name":"标准版包月套餐" //产品名称
|
||
"price":"199", //产品价格(单位: 元)
|
||
"currency":"CNY", //单位(CNY/USD...)
|
||
"state": 0, //状态(0=待上架 1=已上架 2=已下架)
|
||
"language":"zh-CN", //区域语言(中国=zh-CN 英美=en)
|
||
"description":"标准版包月套餐,中小企业福利", //产品描述
|
||
"trial_days": 7, //产品试用期(单位: 天)
|
||
"expiring_days":31 //产品有效期(单位: 天)
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
}
|
||
}
|
||
```
|
||
|
||
## 3.4 删除产品 (管理端)
|
||
|
||
Token: required
|
||
|
||
POST /api/v1/admin/delete/production
|
||
|
||
**请求JSON**
|
||
|
||
```json
|
||
{
|
||
"id": 1 //产品ID (必填)
|
||
}
|
||
```
|
||
|
||
|
||
|
||
**响应JSON**
|
||
|
||
```json
|
||
{
|
||
"header": {
|
||
"code": 0,
|
||
"message": "OK",
|
||
"total": 1,
|
||
"count": 1
|
||
},
|
||
"data": {
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
# 4. 客服前端通信协议
|
||
|
||
[**WEBSOCKET**]
|
||
|
||
ws://116.213.39.234:8084/ws
|
||
|
||
以AI员工的**api key**和**secret key**作为用户名密码采用**BasicAuth**方式鉴权
|
||
|
||
|
||
|
||
## 4.1 文本问文本回复
|
||
|
||
- **请求**
|
||
|
||
```json
|
||
{
|
||
"action": "chat",
|
||
"type": "text", //text: 文本聊天会话 audio: 语音聊天会话
|
||
"content":"中本聪究竟是谁?"
|
||
}
|
||
```
|
||
|
||
- **响应**
|
||
|
||
推流数据结束标记:|=EOF=|
|
||
|
||
```text
|
||
这
|
||
是
|
||
推
|
||
流
|
||
回
|
||
复
|
||
.
|
||
.
|
||
.
|
||
|=EOF=|
|
||
```
|
||
|
||
|
||
|
||
## 4.2 文本问语音回复
|
||
|
||
- 请求
|
||
|
||
```json
|
||
{
|
||
"action": "chat",
|
||
"type": "audio", //text: 文本聊天会话 audio: 语音聊天会话
|
||
"content":"中本聪究竟是谁?"
|
||
}
|
||
```
|
||
|
||
- 响应
|
||
|
||
语音聊天响应结果以|=JSON=|开始,后面紧跟JSON数据,数据中会带上语音推流URL信息
|
||
|
||
```text
|
||
|=JSON=|{"code":0, "message":"OK", "result":{
|
||
"messageId": "sendMessageReplyAudio",
|
||
"conversationId": "thread_y6f7WDDXV8RhvHQwxZrTK6jS",
|
||
"streamUrl": "rtmp://14.17.80.241:11935/lvm/thread_y6f7WDDXV8RhvHQwxZrTK6jS"
|
||
}}
|
||
```
|
||
|
||
失败的情况下返回如下数据
|
||
|
||
```text
|
||
|=JSON=|{"code":502, "message":"dial AI server timeout"}
|
||
```
|
||
|
||
|
||
|
||
## 4.3 语音问语音回复
|
||
|
||
前端通过插件先把用户口述内容转成文字,再调用 **4.2 文本问语音回复** 接口完成通信过程
|
||
|
||
|
||
|