FAQ知识库接口
获取常见问题模板列表
请求地址
- GET /v1/robots/{id:\^[1-9]\d*$}/commonQuestionModels
请求参数
Path parameters
Parameter |
Type |
Optional |
Description |
id |
Integer |
false |
机器人id. |
Query parameters
Parameter |
Type |
Optional |
Description |
pageNum |
int |
true |
大于等于1 |
pageSize |
int |
true |
大于等于1小于等于50 |
searchType |
Integer |
true |
1.按name字段搜索 2.按modelKey字段搜索 |
searchWord |
String |
true |
搜索关键字 |
请求结果
Path |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
Array |
true |
|
data[].id |
Integer |
true |
id. |
data[].robotId |
Integer |
true |
机器人id. |
data[].name |
String |
true |
模板名称. |
data[].description |
String |
true |
模板描述. |
data[].modelKey |
String |
true |
模板标识key modelKey(可以在初始化会话时传递). |
示例
$ curl 'https://km.udesk.cn/api/v1/robots/83/commonQuestionModels?email=admin@udesk.cn×tamp=1540881364&sign=4708c26e84801bf4508a44cfbc110c02dceab794' -i
返回
{
"code" : 200,
"message" : "OK",
"visible" : false,
"data" : [ {
"id" : 88,
"robotId" : 83,
"name" : "默认推荐1",
"description" : "默认推荐",
"modelKey" : "0"
}, {
"id" : 69,
"robotId" : 83,
"name" : "king",
"description" : "引导语进入.....",
"modelKey" : "哎哎哎"
}, {
"id" : 118,
"robotId" : 83,
"name" : "测试",
"description" : "dd",
"modelKey" : "dc"
} ]
}
获取FAQ问题列表
请求地址
- POST /v1/questions/search
请求参数
Request fields
Path |
Type |
Optional |
Description |
pageNum |
Integer |
true |
当前页. |
pageSize |
Integer |
true |
页大小. |
robotId |
Integer |
false |
机器人id. |
categoryId |
Integer |
true |
分类id. |
searchWord |
String |
true |
搜索词. |
searchType |
Integer |
true |
问题或者答案中搜索关键字(可忽略) 1.问题 2.答案 3.答案(默认) |
type |
Integer |
true |
问题类型(可忽略) 1.普通问题 3.流程 4.闲聊 0.全部(默认) |
order |
Integer |
true |
根据更新时间排序 1:正序 2:倒序(可忽略) 默认值:1(正序). |
isWorking |
Integer |
true |
是否生效(可忽略) 默认值:1(全部). |
channelIdList |
Array |
true |
场景列表. |
请求结果
Path |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
Array |
true |
|
data[].id |
Integer |
true |
主问题id. |
data[].robotId |
Integer |
true |
机器人id. |
data[].categoryId |
Integer |
true |
分类id. |
data[].content |
String |
true |
问题内容. |
data[].type |
Integer |
true |
问题类型. |
data[].keyword |
String |
true |
关键字. |
data[].suggestType |
Integer |
true |
建议类型 1,关闭 2,智能推荐 3,手动推荐. |
data[].availableTimeType |
Integer |
true |
生效时间 0 表示永久无效, 1 表示永久有效, 2 表示自定义有效期. |
data[].startTime |
String |
true |
生效时间. |
data[].endTime |
String |
true |
失效时间. |
data[].createTime |
String |
true |
创建时间. |
data[].updateTime |
String |
true |
更新时间. |
data[].similarQuestion |
Array |
true |
相似问法列表. |
data[].similarQuestion[].id |
Integer |
true |
ID. |
data[].similarQuestion[].content |
String |
true |
内容. |
data[].answer |
Object |
true |
问题答案. |
data[].answer.id |
Integer |
true |
ID. |
data[].answer.content |
String |
true |
答案内容. |
data[].answer.type |
Integer |
true |
文本类型 |
data[].suggestList |
Array |
true |
建议列表. |
data[].suggestList[].id |
Integer |
true |
ID. |
data[].suggestList[].content |
String |
true |
内容. |
示例
$ curl 'https://km.udesk.cn/api/v1/questions/search?email=admin@udesk.cn×tamp=1529402458&sign=29beefc01662bd040a74880346f3da4491a357cf' -i -X POST -H 'Content-Type: application/json' -d '{
"pageNum" : 1,
"pageSize" : 10,
"robotId" : 102,
"categoryId" : null,
"searchWord" : "世界",
"searchType" : 3,
"type" : 1,
"order" : 2,
"isWorking" : 1,
"channelIdList" : null
}'
返回
{
"code": 200,
"message": "OK",
"visible": false,
"exception": null,
"paging": {
"pageNum": 1,
"pageSize": 10,
"total": 2
},
"data": [
{
"id": 8657,
"robotId": 102,
"categoryId": 343,
"content": "世界哪里和平了",
"type": 1,
"keyword": "和平",
"suggestType": 3,
"availableTimeType": null,
"startTime": null,
"endTime": null,
"createTime": "2018-05-30 17:06:13",
"updateTime": "2018-10-31 13:57:47",
"similarQuestion": null,
"answer": {
"id": 4442,
"content": "<p>没有</p>\n<p><audio style=\"display: none;\" controls=\"controls\"></audio></p>\n<p><audio style=\"display: none;\" controls=\"controls\"></audio></p>",
"type": 2
},
"suggestList": [
{
"id": 9253,
"content": "床前明月光啊"
},
{
"id": 9257,
"content": "怎么说英语"
}
]
},
{
"id": 8656,
"robotId": 102,
"categoryId": 343,
"content": "世界和平吗",
"type": 1,
"keyword": "和平",
"suggestType": 3,
"availableTimeType": null,
"startTime": null,
"endTime": null,
"createTime": "2018-05-30 17:05:53",
"updateTime": "2018-10-30 18:23:12",
"similarQuestion": [
{
"id": 9432,
"content": "世界和平吗1"
}
],
"answer": {
"id": 4441,
"content": "<p>不和平</p>\n<p><audio style=\"display: none;\" controls=\"controls\"></audio></p>\n<p><audio style=\"display: none;\" controls=\"controls\"></audio></p>",
"type": 2
},
"suggestList": [
{
"id": 8657,
"content": "世界哪里和平了"
},
{
"id": 9259,
"content": "你想去哪儿"
}
]
}
],
"extra": null
}
获取FAQ问题详情
请求地址
- GET /v1/questions/{id:\^[1-9]\d*$}
请求参数
Path parameters
Parameter |
Type |
Optional |
Description |
id |
int |
false |
ID. |
请求结果
Path |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
Object |
true |
|
data.id |
Integer |
true |
主问题id. |
data.robotId |
Integer |
true |
机器人id. |
data.categoryId |
Integer |
true |
分类id. |
data.content |
String |
true |
问题内容. |
data.type |
Integer |
true |
类型 1:普通问题 2:相似问题 3:流程入口问题. 4:闲聊 |
data.keyword |
String |
true |
关键字. |
data.suggestType |
Integer |
true |
建议类型 1,关闭 2,智能推荐 3,手动推荐. |
data.availableTimeType |
Integer |
true |
生效时间 0 表示永久无效, 1 表示永久有效, 2 表示自定义有效期. |
data.startTime |
String |
true |
生效时间. |
data.endTime |
String |
true |
失效时间. |
data.createTime |
String |
true |
创建时间. |
data.updateTime |
String |
true |
更新时间. |
data.needLearnCount |
Integer |
true |
需要学习数量. |
data.similarQuestion |
Array |
true |
相似问法列表. |
data.similarQuestion[].id |
Integer |
true |
ID. |
data.similarQuestion[].content |
String |
true |
内容. |
data.similarQuestion[].type |
Integer |
true |
类型 1:普通问题 2:相似问题 3:流程入口问题. 4:闲聊 |
data.similarQuestion[].orders |
Integer |
true |
排序. |
data.answer |
Object |
true |
问题答案. |
data.answer.id |
Integer |
true |
ID. |
data.answer.content |
String |
true |
答案内容. |
data.answer.type |
Integer |
true |
文本类型 1:纯文本 2:富文本 3:语音 4.链接 5.图片 |
data.suggestList |
Array |
true |
建议列表. |
data.suggestList[].id |
Integer |
true |
ID. |
data.suggestList[].content |
String |
true |
内容. |
data.suggestList[].type |
Integer |
true |
类型 1:普通问题 2:相似问题 3:流程入口问题. 4:闲聊 |
data.suggestList[].orders |
Integer |
true |
排序. |
data.channelList |
Array |
true |
存放场景列表. |
data.channelList[].id |
Integer |
true |
id. |
data.channelList[].robotId |
Integer |
true |
机器人Id. |
data.channelList[].name |
String |
true |
场景名. |
data.channelList[].description |
String |
true |
场景描述. |
data.channelList[].type |
Integer |
true |
type 1:默认 2:非默认. |
示例
$ curl 'https://km.udesk.cn/api/v1/questions/1232?email=admin@udesk.cn×tamp=1529402455&sign=d4be213127c62bb5b53dea5f5e52eaad06b2362f' -i -H 'Accept: application/json'
返回
{
"code": 200,
"message": "OK",
"visible": false,
"exception": null,
"paging": null,
"data": {
"id": 1232,
"robotId": 83,
"categoryId": 295,
"content": "还款出现异常情况怎么办?",
"type": 1,
"keyword": "",
"suggestType": 1,
"availableTimeType": 1,
"startTime": null,
"endTime": null,
"createTime": "2018-02-28 18:32:23",
"updateTime": "2018-06-13 15:20:04",
"needLearnCount": null,
"similarQuestion": null,
"answer": {
"id": 727,
"content": "如果您在还款过程中或还款后出现异常情况,请保留好操作截图,并第一时间联系人工客服寻求帮助哦!",
"type": 2
},
"suggestList": null,
"channelList": [
{
"id": 82,
"robotId": 83,
"name": "系统默认场景",
"description": "系统默认场景",
"type": 1
}
]
},
"extra": null
}
异常响应结果
{
"code": 400,
"message": "{具体的异常信息}",
"visible": false
}
message列表:
问题不存在或已删除
新建FAQ问题
请求地址
请求参数
Request fields
Path |
Type |
Optional |
Description |
robotId |
Integer |
false |
机器人ID. |
categoryId |
Integer |
false |
分类ID. |
content |
String |
false |
问题内容. 不超过200字符 |
type |
Integer |
false |
问题类型 1:普通问题 2:相似问题 3:流程入口问题. 4.闲聊 |
mainId |
Integer |
true |
主问题ID(默认为0). |
similarQuestions |
Array |
true |
相似问法.每个相似问法内容不超过200字符 |
answer |
Object |
false |
答案(当type = 3 流程时,此字段为描述). |
answer.content |
String |
true |
答案内容. |
answer.type |
Integer |
true |
文本类型.1:纯文本 2:富文本 3:语音 4.链接 5.图片 |
channelList |
Array |
false |
场景列表. |
channelList[].id |
Integer |
true |
场景ID. |
availableTimeType |
Integer |
true |
生效时间 0 表示永久无效, 1 表示永久有效, 2 表示自定义有效期. |
startTime |
String |
true |
问题生效时间. |
endTime |
String |
true |
问题失效时间. |
keyword |
String |
true |
关键词:逗号分割. |
suggestType |
Integer |
false |
推荐类型 1,关闭 2,智能推荐 3,手动推荐. |
suggestsList |
Array |
true |
如果推荐类型为手动推荐,则推荐问题id放入此列表中. |
suggestsList[].id |
Integer |
true |
ID. |
isSwitchStaff |
Integer |
true |
推荐转人工. |
flow |
Object |
true |
创建流程入口. |
flow.robotId |
Integer |
false |
机器人id. |
flow.name |
String |
false |
流程子项问题. |
flow.content |
String |
false |
流程子项答案. |
请求结果
Parameter |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
Object |
true |
|
data.id |
Integer |
true |
主问题id. |
data.robotId |
Integer |
true |
机器人id. |
data.categoryId |
Integer |
true |
分类id. |
data.content |
String |
true |
问题内容. |
data.type |
Integer |
true |
问题类型. |
data.keyword |
String |
true |
关键字. |
data.suggestType |
Integer |
true |
建议类型 1,关闭 2,智能推荐 3,手动推荐. |
data.availableTimeType |
Integer |
true |
生效时间 0 表示永久无效, 1 表示永久有效, 2 表示自定义有效期. |
data.startTime |
String |
true |
生效时间. |
data.endTime |
String |
true |
失效时间. |
data.createTime |
String |
true |
创建时间. |
data.updateTime |
String |
true |
更新时间. |
data.similarQuestion |
Array |
true |
相似问法列表. |
data.similarQuestion[].id |
Integer |
true |
ID. |
data.similarQuestion[].content |
String |
true |
内容. |
data.similarQuestion[].type |
Integer |
true |
类型 1:普通问题 2:相似问题 3:流程入口问题 4:闲聊 |
data.answer |
Object |
true |
问题答案. |
data.answer.id |
Integer |
true |
ID. |
data.answer.content |
String |
true |
答案内容. |
data.answer.type |
Integer |
true |
文本类型 1:纯文本 2:富文本 3:语音 4.链接 5.图片 |
data.suggestList |
Array |
true |
建议列表. |
data.suggestList[].id |
Integer |
true |
ID. |
data.suggestList[].content |
String |
true |
内容. |
data.suggestList[].type |
Integer |
true |
类型 1:普通问题 2:相似问题 3:流程入口问题 4:闲聊 |
data.channelList |
Array |
true |
存放场景列表. |
data.channelList[].id |
Integer |
true |
id. |
data.channelList[].robotId |
Integer |
true |
机器人Id. |
data.channelList[].name |
String |
true |
场景名. |
data.channelList[].description |
String |
true |
场景描述. |
data.channelList[].type |
Integer |
true |
type 1:默认 2:非默认. |
示例
$ curl 'https://km.udesk.cn/api/v1/questions?email=admin@udesk.cn×tamp=1529402459&sign=814452f1c81d0f43303a30c4a6fd1c894d152ef3' -i -X POST -H 'Content-Type: application/json' -d '{
"robotId" : 102,
"categoryId" : 343,
"content" : "身份证怎么办理",
"type" : 1,
"mainId" : 0,
"similarQuestions" : ["身份证去哪里办理","身份证如何办理"],
"answer" : {
"content" : "百度一下,你就知道",
"type" : 1
},
"channelList" : [ {
"id" : 105
} ],
"availableTimeType" : 1,
"startTime" : null,
"endTime" : null,
"keyword" : "身份证,身份证明",
"suggestType" : 1,
"suggestsList" : null,
"isSwitchStaff" : null,
"flow" : null
}'
返回
{
"code": 200,
"message": "OK",
"visible": false,
"exception": null,
"paging": null,
"data": {
"id": 9458,
"robotId": 102,
"categoryId": 343,
"content": "身份证怎么办理",
"type": 1,
"keyword": "身份证,身份证明",
"suggestType": 1,
"availableTimeType": 1,
"startTime": null,
"endTime": null,
"createTime": "2018-10-31 11:12:39",
"updateTime": "2018-10-31 11:12:39",
"similarQuestion": [
{
"id": 9459,
"content": "身份证去哪里办理",
"type": 2
},
{
"id": 9460,
"content": "身份证如何办理",
"type": 2
}
],
"answer": {
"id": 5142,
"content": "百度一下,你就知道",
"type": 1
},
"suggestList": null,
"channelList": [
{
"id": 105,
"robotId": 102,
"name": "系统默认场景",
"description": "系统默认场景",
"type": 1
}
]
},
"extra": null
}
异常响应结果
{
"code": 400,
"message": "{具体的异常信息}",
"visible": false
}
message列表:
分类不存在
非叶子节点分类不能添加问题
您的知识库已到达上限,如需升级知识库容量,请联系Udesk
该机器人不存在或已删除
分类不属于该机器人
场景不存在或已经被删除!场景ID:{0}
场景不属于该机器人!场景ID:{0}
启动生效时间后,时间范围不可为空
与现有问题重复!问题Id:{0}
非叶子节点分类不能添加问题
答案内容不能为空
请选择至少一个场景
相似问法不符合要求(相似问法不能为空字符且长度不能大于200个字符!)
流程子项问题不能为空
流程子项问题长度不能超过100个字符
流程子项问题不能重复
流程子项答案不能为空
流程子项数不能多于300
删除FAQ问题
请求地址
- DELETE /v1/questions/{id:\^[1-9]\d*$}
请求参数
Path parameters
Parameter |
Type |
Optional |
Description |
id |
int |
false |
ID. |
请求结果
Path |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
null |
true |
|
示例
$ curl 'https://km.udesk.cn/api/v1/questions/9362?email=admin@udesk.cn×tamp=1529402460&sign=87e3763301d72ad81aacc823883c3c96a5fcbcfc' -i -X DELETE -H 'Content-Type: application/json'
返回
{
"code" : 200,
"message" : "OK",
"visible" : false,
"data" : null
}
编辑FAQ问题
请求地址
- PUT /v1/questions/{id:\^[1-9]\d*$}
请求参数
Path parameters
Parameter |
Type |
Optional |
Description |
id |
int |
false |
ID. |
Request fields
Path |
Type |
Optional |
Description |
id |
Integer |
true |
ID. |
categoryId |
Integer |
false |
分类ID. |
content |
String |
false |
问题内容. 不超过200字符 |
type |
Integer |
true |
问题类型. 1:普通问题 2:相似问题 3:流程入口问题. 4.闲聊 |
answerUpdateRequest |
Object |
false |
答案. |
answerUpdateRequest.id |
Integer |
false |
答案ID. |
answerUpdateRequest.content |
String |
false |
答案内容. |
answerUpdateRequest.type |
Integer |
true |
文本类型 1:纯文本 2:富文本 3:语音 4.链接 5.图片 |
simpleChannelList |
Array |
false |
场景列表. |
simpleChannelList[].id |
Integer |
false |
场景ID. |
availableTimeType |
Integer |
true |
生效时间 0 表示永久无效, 1 表示永久有效, 2 表示自定义有效期. |
startTime |
String |
true |
问题生效时间. |
endTime |
String |
true |
问题失效时间. |
keyword |
String |
true |
关键词. |
suggestType |
Integer |
true |
推荐类型 1:关闭 2:智能推荐 3:手动推荐. |
suggestsList |
Array |
true |
推荐列表 当type为手动推荐时,推荐列表不为空. |
suggestsList[].id |
Integer |
true |
ID. |
simpleQuestionUpdateRequests |
Array |
true |
相似问题列表. |
simpleQuestionUpdateRequests[].id |
Integer |
true |
ID. |
simpleQuestionUpdateRequests[].content |
String |
false |
内容. |
isSwitchStaff |
Integer |
true |
推荐转人工. |
请求结果
Path |
Type |
Optional |
Description |
code |
Integer |
true |
|
message |
String |
true |
|
visible |
Boolean |
true |
|
data |
null |
true |
|
示例
$ curl 'https://km.udesk.cn/api/v1/questions/9458?email=admin@udesk.cn×tamp=1529402462&sign=62a0c09fad0446c6bc24fa1ec876ee2eb789297a' -i -X PUT -H 'Content-Type: application/json' -d '{
"id":9458,
"categoryId" : 343,
"content" : "身份证怎么办理啊",
"type": 1,
"answerUpdateRequest" : {
"id": 5142,
"content" : "google一下,你就知道",
"type" : 1
},
"simpleChannelList" : [ {
"id" : 105
} ],
"availableTimeType" : 1,
"startTime" : null,
"endTime" : null,
"suggestType" : 1,
"suggestsList" : null,
"isSwitchStaff" : null
}'
返回
{
"code" : 200,
"message" : "OK",
"visible" : false,
"data" : null
}
异常响应结果
{
"code": 400,
"message": "{具体的异常信息}",
"visible": false
}
message列表:
问题不存在或已删除
该问题答案未找到
分类不存在
非叶子节点分类不能添加问题
您的知识库已到达上限,如需升级知识库容量,请联系Udesk
该机器人不存在或已删除
分类不属于该机器人
场景不存在或已经被删除!场景ID:{0}
场景不属于该机器人!场景ID:{0}
启动生效时间后,时间范围不可为空
与现有问题重复!问题Id:{0}
非叶子节点分类不能添加问题
请选择至少一个场景
相似问法不符合要求(相似问法不能为空字符且长度不能大于200个字符!)