目录

知识库接口


JSON格式

名称 类型 只读 必填 注释
kId int 知识库ID,系统自动生成
url varchar 该知识库的资源url
sQuestion varchar 知识库的标题
sAnswer varchar 知识库的答案,带css样式返回,如果答案里有图片、文件等附件,则会以html标签页的形式返回
sAttachment array 知识库答案里的附件,新建知识库时,会用到该参数
servicerId int 添加知识库的客服ID
state tinyint 知识库的状态:0-未审核,1-已审核。管理员添加的知识库状态默认为已审核
reviewerId int 审核知识库的客服ID
goodRate int 该条知识库的好评率
badRate int 该条知识库的差评率
adoptCount int 该条知识库被采纳次数
isFAQ tinyint 该条知识库是否被设为了常见问题:0-非常见问题,1-常见问题,默认不是常见问题,常见问题条数不能超过10条
relatedQuestion varchar 该条知识库的关联问题
similarQuestion varchar 该条知识库的相似问题,id展示相似问题的id,sqname展示相似问题名称
createDT datetime 创建时间,格式为:2018-02-08 9:12:20
updateDT datetime 更新时间,格式为:2018-02-08 9:12:20
fId int 分类id(如果想获取“未分类”中的问题,该参数请传值“not”)

JSON示例

{
    "kId":1,
    "url":"https://www.bangwo8.com/api/v1/knowledge/1.json",
    "sQuestion":"请问帮我吧有哪些功能模块?",
    "sAnswer":"呼叫中心、IM、工单",
    "sAttachment":"",
    "servicerId":"324",
    "state":"0",
    "reviewerId":"321",
    "goodRate":"70%",
    "badRate":"30%",
    "adoptCount":"2",
    "isFAQ":"1",
    "relatedQuestion":"帮我吧是分模块的吗?",
    "similarQuestion":[
        {
            "id":"111",
            "sqname":"帮我吧有哪些功能?"
        },
        {
            "id":"122",
            "sqname":"帮我吧的功能列表"
        }
    ],
    "createDT":"2018-02-05 10:20:20",
    "updateDT":"2018-02-08 9:12:20",
    "fId":"无分类"
}

获取知识库列表

GET /api/v1/knowledge.json

查询参数

名称 必需的 类型 注释
created_start string 按创建时间筛选,开始时间
created_end string 按创建时间筛选,结束时间
updated_start string 按更新时间查询:开始时间
updated_end string 按更新时间查询:结束时间
created_order string 按创建时间排序:asc(升序),desc(降序)
updated_order string 按更新时间排序:asc(升序),desc(降序)
page int 分页获取,默认为1
per_page int 每页大小,默认为40,最大限制位40
fId int 分类id(获取该分类下的问题,不能获取子集的问题)

说明:默认按编码升序返回。时间参数(created_start、created_end、updated_start、updated_end)格式为“2012-01-01 00:00:00”。

调用者权限

所有客服

调用示例

curl https://www.bangwo8.com/api/v1/knowledge.json \
  -v -u {account}:{password}

返回值示例

Status: 200 OK

{
	"knowledge": [
		{
			"kId": "8741",
                        "sQuestion": "晶体管的代换原则",
                        "sAnswer": "类型相同、特性相近、外形相似",
                        "servicerId": "0",
                        "state": "0",
                        "reviewerId": "",
                        "goodRate": "0",
                        "badRate": "0",
                        "adoptCount": "0",
                        "isFAQ": "0",
                        "relatedQuestion": "",
                        "createDT": "0000-00-00 00:00:00",
                        "updateDT": "2016-06-28 10:55:04",
                        "similarQuestion": "",
                        "fId": "无分类"
		},
		{
			"kId": "8745",
                        "sQuestion": "什么是三极管?",
                        "sAnswer": "三极管是一种用于放大或开关电信号的半导体器件,下图是一些常用三极管的典型封装和主要参数:",
                        "servicerId": "0",
                        "state": "0",
                        "reviewerId": "",
                        "goodRate": "0",
                        "badRate": "0",
                        "adoptCount": "0",
                        "isFAQ": "0",
                        "relatedQuestion": "",
                        "createDT": "0000-00-00 00:00:00",
                        "updateDT": "2016-06-28 10:55:04",
                        "similarQuestion": "",
                        "fId": "无分类"
		}
                ...
	],
        "count": 42,
        "next_page": "https://www.bangwo8.com/api/v1/knowledge.json?per_page=40&page=2",
        "previous_page": null
}

查看单条知识库信息

GET /api/v1/knowledge/{id}.json

调用者权限

所有客服

调用示例

curl https://www.bangwo8.com/api/v1/knowledge/{id}.json \
  -v -u {account}:{password}

返回值示例

Status: 200 OK

{
    "knowledge": {
        "kId": "8741",
        "sQuestion": "晶体管的代换原则",
        "sAnswer": "类型相同、特性相近、外形相似",
        "servicerId": "0",
        "state": "0",
        "reviewerId": "",
        "goodRate": "0",
        "badRate": "0",
        "adoptCount": "0",
        "isFAQ": "0",
        "relatedQuestion": "",
        "similarQuestion": "",
        "createDT": "0000-00-00 00:00:00",
        "updateDT": "2016-06-28 10:55:04",
        "fId": "无分类"
    }
}

查看多条知识库信息

GET /api/v1/knowledge/show_many.json?ids={ids}

调用者权限

所有客服

调用示例

curl https://www.bangwo8.com/api/v1/knowledge/show_many.json?ids=8741,8745 \
  -v -u {account}:{password}

返回值示例

Status: 200 OK

{
    "knowledge": [
        {
            "kId": "8741",
            "sQuestion": "晶体管的代换原则",
            "sAnswer": "类型相同、特性相近、外形相似",
            "servicerId": "0",
            "state": "0",
            "reviewerId": null,
            "goodRate": "0",
            "badRate": "0",
            "adoptCount": "0",
            "isFAQ": "0",
            "relatedQuestion": "",
            "createDT": "0000-00-00 00:00:00",
            "updateDT": "2016-06-28 10:55:04",
            "fId": "无分类"
        },
        {
            "kId": "8745",
            "sQuestion": "什么是三极管?",
            "sAnswer": "三极管是一种用于放大或开关电信号的半导体器件,下图是一些常用三极管的典型封装和主要参数:",
            "servicerId": "0",
            "state": "0",
            "reviewerId": null,
            "goodRate": "0",
            "badRate": "0",
            "adoptCount": "0",
            "isFAQ": "0",
            "relatedQuestion": "",
            "createDT": "0000-00-00 00:00:00",
            "updateDT": "2016-06-28 10:55:04",
            "fId": "无分类"
        }
    ]
}

新建知识库

POST /api/v1/knowledge.json

调用者权限

管理员

调用示例

知识库答案为纯文本,无附件,示例如下:

curl -v -u {account}:{password} https://www.bangwo8.com/api/v1/knowledge.json \
  -H "Content-Type: application/json" -X POST -d '{"knowledge": {"sQuestion": "帮我吧有哪些模块", \
  "sAnswer": "IM、呼叫中心和工单",\ "fId": 123}}'

说明:新建知识库时,sQuestion和sAnswer必填。如果知识库答案带样式,请将css样式也放到post请求里。



知识库答案带附件,示例如下:

curl -v -u {account}:{password} https://www.bangwo8.com/api/v1/knowledge.json \
  -H "Content-Type: application/json" -X POST -d '{"knowledge": {"sQuestion": "这里是知识库问题", \
  "sAnswer": "这里是知识库答案,答案里有附件,这是一个附件{1},这又是一个附件{2},还有一个附件{3}", \
  "sAttachment": "token1,token2,token3"}}

说明:
1、如果知识库答案带附件,需先调用上传附件 接口,系统会返回附件对应的token,然后将该token设置到“sAttachment”里。
2、“sAnswer”值里的{数字}是附件的占位,为可自定义的内容,须从1开始连续编号,如{1}、{2}等。
3、“sAttachment”为知识库答案里所有的附件列表,以逗号分隔每个附件,列表的顺序对应“sAnswer”里的{数字}部分。

返回值示例

Status: 200 OK
Location: https://www.bangwo8.com/api/v1/knowledge/{id}.json

{
  "knowledge": {
    "kId":   11,
    "sQuestion": "我是知识库问题",
    ...
  }
}

上传附件

POST /api/v1/attachments.json

说明:
1、url里需要增加filename参数来设置附件名
2、请求header里要设置”Content-Type: application/binary“
3、仅支持一次上传一个附件

调用者权限

所有客服

调用示例

curl "https://www.bangwo8.com/api/v1/attachments.json?filename=myfile.dat" \
  -v -u {account}:{password} \
  -H "Content-Type: application/binary" \
  --data-binary @file.dat -X POST

返回值示例

Status: 201 Created
Location: https://www.bangwo8.com/api/v1/attachments/{id}.json

{
	"attachment": {
		"attachId": 123,
		"fileName": "file.png",
		"filePath": "https://bangwo8.oss-cn-shenzhen.aliyuncs.com/18/Z28tfzPdB.png",
		"token": "15761b339251466e9fec23698503eb53"
	}
}

修改知识库

PUT /api/v1/knowledge/{id}.json

调用者权限

所有客服

调用示例

curl -v -u {account}:{password} https://www.bangwo8.com/api/v1/knowledge/123.json \
  -H "Content-Type: application/json" -X PUT -d '{"knowledge": {"sAnswer": "修改后的答案"}}'

返回值示例

Status: 200 OK

{
  "knowledge": {
    "kId":   11,
    "name": "知识库的问题",
    ...
  }
}