Skip to content

获取聊天记录

GET /visitor/message/get

按消息 ID 游标获取当前访客的历史消息。首次请求不传 mid;服务端会同时处理首屏消息的已读状态。

请求参数

字段位置类型必填用途
agent_idquerystring | number当前会话客服 ID。
limitquerynumber返回数量,默认 20,最大 100
midquerynumber向前翻页游标;仅返回小于该值的消息。

成功响应

json
{
  "code": 0,
  "msg": "ok",
  "data": [
    {
      "mid": 1024,
      "from": "<访客 UID 或客服 ID>",
      "nickname": "<发送者昵称>",
      "avatar": "<发送者头像>",
      "timestamp": 1730000000,
      "content": "<消息正文>",
      "translated_content": "<翻译后的正文或空字符串>",
      "sub_type": "message",
      "author": "visitor",
      "readed": "readed"
    }
  ]
}
字段类型用途
dataarray消息列表,按时间正序返回。
data[].midnumber服务端消息 ID,也是下一页游标依据。
data[].fromstring | number发送方 ID;访客消息为 UID,客服消息为客服 ID。
data[].nicknamestring发送方展示昵称。
data[].avatarstring发送方头像地址。
data[].timestampnumberUnix 秒级时间戳。
data[].contentstring原始消息正文。
data[].translated_contentstring已生成的译文;没有译文时为空字符串。
data[].sub_typestring消息子类型,例如 messagenotice
data[].authorstringvisitoragent
data[].readedstring已读状态。