会话主题、历史与记录
使用平台 API Key,要求 app_chat_record=READ(或可读写权限)。请求头为 Authorization: Bearer tk-...。用户编码关联方法见 访客注册与用户关联。
会话主题列表
GET /openapi/paas/chat/topic/list
注意本路径在 paas 后没有 v1。
| Query 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
userId | string | 否 | 创建会话使用的 AIS 用户标识;省略时使用当前鉴权用户 code |
topic | string | 否 | 主题模糊查询 |
pageNo | integer | 否 | 默认 1 |
pageSize | integer | 否 | 默认 10 |
curl --get "${BASE_URL}/openapi/paas/chat/topic/list" \
--header "Authorization: Bearer ${AIS_API_KEY}" \
--data-urlencode "userId=partner_visitor_10001" \
--data-urlencode "pageNo=1" \
--data-urlencode "pageSize=10"
响应字段
按创建人筛选未删除会话,创建时间倒序。顶层字段见 分页响应,data[] 条目如下:
| 字段 | JSON 类型 | 说明 |
|---|---|---|
id | integer | /主/键/i/d/ |
creator | string | /会/话/创/建/人/标/识/,/用/于/关/联/创/建/会/话/时/的/用/户/ |
createTime | string | /创/建/时/间/;日期时间字符串,可无时区偏移 |
modifier | string | /修/改/人/ |
modifierTime | string | /修/改/时/间/;日期时间字符串,可无时区偏移 |
sort | integer | /排/序/ |
userCode | string | /用/户/编/码/扩/展/,/可/能/为/空/;/查/询/身/份/以/请/求/和/创/建/人/过/滤/为/准/ |
conversationId | string | /对/话/i/d/ |
topic | string | /当/前/对/话/主/题/ |
响应示例
{
"code": 8200,
"message": "SUCCESS",
"pageNo": 1,
"pageSize": 10,
"total": 1,
"totalPage": 1,
"data": [{
"id": 101,
"creator": "partner_visitor_10001",
"createTime": "2026-09-05T10:30:00",
"modifier": null,
"modifierTime": null,
"sort": 0,
"userCode": "partner_visitor_10001",
"conversationId": "conversation_001",
"topic": "产品部署咨询"
}]
}
会话历史
GET /openapi/paas/chat/topic/history
| Query 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
conversationId | string | 是 | 对话或主题列表返回的会话 ID |
userId | string | 否 | 与创建会话使用的用户标识一致;省略时使用当前鉴权用户 |
curl --get "${BASE_URL}/openapi/paas/chat/topic/history" \
--header "Authorization: Bearer ${AIS_API_KEY}" \
--data-urlencode "userId=partner_visitor_10001" \
--data-urlencode "conversationId=REPLACE_WITH_CONVERSATION_ID"
返回 Result 包装,data 为数组。当前取符合条件的最近 50 条,再按时间正序返回;该接口没有翻页参数,不是完整历史导出接口。
响应字段
| 字段 | JSON 类型 | 说明 |
|---|---|---|
question | string | /问/题/ |
messageId | string | /消/息/i/d/ |
conversationId | string | /会/话/ /I/D/ |
tenantId | string | /租/户/编/码/ |
userId | string | /生/成/记/录/时/的/用/户/标/识/ |
likeState | integer | /点/赞/状/态/扩/展/:/0/ /无/、/1/ /赞/、/2/ /踩/;/当/前/历/史/组/装/可/能/未/填/充/,/n/u/l/l/ /不/等/于/已/点/赞/ |
modelName | string | /模/型/ |
fileSource | string | /来/源/信/息/的/序/列/化/字/符/串/,/可/空/;/不/是/直/接/嵌/套/的/ /J/S/O/N/ /数/组/ |
content | string | /答/案/ |
costTime | integer | /处/理/耗/时/,/毫/秒/ |
createTime | string | /创/建/日/期/;日期时间字符串,可无时区偏移 |
type | string | /记/录/反/馈/类/型/扩/展/,/可/空/;/不/作/为/ /u/s/e/r///a/s/s/i/s/t/a/n/t/ /消/息/角/色/ |
响应示例
{
"code": 8200,
"message": "SUCCESS",
"data": [{
"question": "产品支持哪些部署方式?",
"messageId": "message_001",
"conversationId": "conversation_001",
"tenantId": "partner_tenant_001",
"userId": "partner_visitor_10001",
"likeState": null,
"modelName": "configured-model",
"fileSource": null,
"content": "支持按项目约定进行部署。",
"costTime": 1200,
"createTime": "2026-09-05T10:30:00",
"type": null
}]
}
主题和历史的 userId 是查询选择条件;对接服务端必须校验外部用户与 AIS 用户、会话之间的归属,不向客户端开放任意用户查询代理。
分页查询会话记录
GET /openapi/paas/v1/message/list
此接口用于当前租户内的记录查询,返回答案类记录,适合按日期和会话分页查看。它与上面的主题历史接口不是相同查询口径。
| Query 参数 | 类型 | 必填 | 当前生效的筛选 |
|---|---|---|---|
question | string | 否 | 问题模糊匹配 |
conversationId | string | 否 | 会话 ID |
appid | string | 否 | 应用 ID |
userId | string | 否 | 对话用户标识 |
startTime | string | 建议显式传 | yyyy-MM-dd;省略时回溯约六个月 |
endTime | string | 建议显式传 | yyyy-MM-dd,包含当天;省略时由服务端计算 |
sort | string | 否 | asc、desc,默认 desc |
pageNo、pageSize | integer | 否 | 默认 1、10 |
时间区间应控制在六个月以内。请求模型中的 userName、containId、platform 在此路径当前的查询分支未参与过滤,不应作为结果隔离条件。
curl --get "${BASE_URL}/openapi/paas/v1/message/list" \
--header "Authorization: Bearer ${AIS_API_KEY}" \
--data-urlencode "userId=partner_visitor_10001" \
--data-urlencode "startTime=2026-09-01" \
--data-urlencode "endTime=2026-09-05" \
--data-urlencode "pageNo=1" \
--data-urlencode "pageSize=10"
响应字段
顶层为标准分页。以下字段位于 data[];来源、错误和诊断字段按记录来源填充,不保证每项都有值。
| 字段 | JSON 类型 | 说明 |
|---|---|---|
id | integer | /主/键/i/d/ |
messageId | string | /消/息/i/d/ |
conversationId | string | /对/话/i/d/ |
parentMessageId | string | /上/文/i/d/ |
apiType | string | /a/p/i/类/型/ |
questionCount | integer | /连/续/问/题/数/量/,/第/一/条/消/息/是/1/ |
question | string | /问/题/描/述/ |
originalData | string | /记/录/的/原/始/数/据/字/符/串/,/可/空/,/可/能/含/业/务/内/容/ |
userId | string | /提/问/人/用/户/i/d/ |
userName | string | /用/户/展/示/名/称/ |
platform | string | /提/问/来/源/平/台/:/P/C/-/网/页/端/,/A/P/I/-/A/P/I/接/口/,/J/S//S/D/K/-/网/页/嵌/入/式/,/L/A/R/K/-/飞/书/,/Q/Y//W/E/C/H/A/T/-/企/业/微/信/,/D/I/N/G/_/T/A/L/K/-/钉/钉/ |
eventSource | string | /会/话/记/录/事/件/来/源/ |
sourceName | string | /来/源/名/称/,/例/如/应/用/或/知/识/库/名/称/;/未/匹/配/可/空/ |
ip | string | /用/户/i/p/ |
status | integer | /记/录/状/态/标/识/,/按/实/际/返/回/值/处/理/,/不/替/代/外/层/业/务/ /c/o/d/e/ |
type | string | /反/馈/类/型/:/l/i/k/e/ /赞/、/t/a/p/ /踩/;/可/空/ |
modelName | string | /模/型/名/称/ |
content | string | /消/息/内/容/ |
messageType | integer | /1/ /问/题/、/2/ /答/案/;/本/接/口/查/询/答/案/类/记/录/ |
responseErrorData | string | /失/败/诊/断/内/容/,/可/空/;/不/要/直/接/公/开/ |
fileSource | string | /来/源/信/息/的/序/列/化/ /J/S/O/N/ /字/符/串/,/可/空/;/需/要/时/二/次/解/析/ |
costTime | integer | /生/成/耗/时/,/毫/秒/ |
startTime | integer | /开/始/时/间/戳/,/毫/秒/ |
creator | string | /创/建/人/ |
createTime | string | /创/建/时/间/;日期时间字符串,可无时区偏移 |
modifier | string | /修/改/人/ |
modifiedTime | string | /修/改/时/间/;日期时间字符串,可无时区偏移 |
timeLogs | string | /处/理/日/志/字/符/串/,/可/空/,/仅/可/信/服/务/端/排/查/使/用/ |
响应示例
示例省略可空的原始数据和诊断字段:
{
"code": 8200,
"message": "SUCCESS",
"pageNo": 1,
"pageSize": 10,
"total": 1,
"totalPage": 1,
"data": [{
"id": 201,
"messageId": "message_001",
"conversationId": "conversation_001",
"question": "产品支持哪些部署方式?",
"content": "支持按项目约定进行部署。",
"userId": "partner_visitor_10001",
"userName": "访客",
"messageType": 2,
"costTime": 1200,
"createTime": "2026-09-05T10:30:00",
"fileSource": null
}]
}
应用主题配置
应用页面外观与会话主题不是同一资源。入口 GET /openapi/paas/v1/theme/{appid} 的请求、完整字段和示例已独立到 应用展示配置。
无结果与错误处理
主题列表、历史数组和记录分页可能正常返回空集合;先检查 userId、conversationId、日期范围是否与记录一致,再检查该用户是否实际发起过对话。无结果不应触发重新注册用户。
参数、凭据、权限失败按 错误处理 处理。记录含问题正文、用户信息及可能的诊断数据,只向当前有权访问的用户提供必要字段。