Skip to content

获取指定消息内容

获取指定message_id的内容:

  • 获取单聊消息时,仅能是该应用的单聊
  • 获取群聊消息时,机器人必须在被查询的群组中

请求说明

请求地址https://openapi.wps.cn/v7/chats/{chat_id}/messages/{message_id}
请求方法GET
签名方式KSO-1
权限要求查询和管理会话消息(应用授权) kso.chat_message.readwrite

请求头(Header)

Header 名称参数类型是否必填说明
Content-Typestring使用:application/json
X-Kso-DatestringRFC1123 格式的日期,例: Wed, 23 Jan 2013 06:43:08 GMT
X-Kso-AuthorizationstringKSO-1 签名值,详见《签名方法》
Authorizationstring授权凭证,格式为:Bearer {access_token}

路径参数(Path)

名称参数类型是否必填说明
chat_idstring会话 id
message_idstring消息 id

请求地址示例

[GET] https://openapi.wps.cn/v7/chats/{chat_id}/messages/{message_id}

响应体

名称参数类型说明
codeinteger响应代码。非 0 表示失败,参照《状态码说明》
msgstring响应信息
dataobject数据信息
∟ idstring消息id
∟ typestring消息类型:text:文本;rich_text:富文本;image:图片;
file:文件;audio:音频;video:视频;card:卡片消息
∟ ctimeint消息生成的时间戳
∟ quote_msg_idstring被引用的消息ID
∟ positionint会话消息位置索引,严格连续递增
∟ contentobject消息内容,根据不同消息类型type,返回不同的消息内容,详见:消息内容(content)结构说明
∟ senderobject发送者
∟ ∟ typestring发送者类型:user-用户,sp-应用服务主体
∟ ∟ idstring发送者的 ID,当发送者类型为user时返回user_id,当发送者类型为sp时返回spid(与应用appid不相同)
∟ ∟ app_idstring应用id,只在type为sp时有值
∟ ∟ company_idstring发送者所属企业
∟ mentionsarray消息@人列表
∟ ∟ typestringat 操作对象类型
all:所有人;user:用户
∟ ∟ idstring指定聊天消息中at操作的实体索引ID。与消息正文中相应 标记中的 {index} 值匹配
∟ ∟ identityobject被 at 的用户信息,当 at 所有人时该值为空
∟ ∟ ∟ company_idstring被 at 的用户所属企业id
∟ ∟ ∟ idstring被 at 的用户id
∟ ∟ ∟ typestring被 at 的用户类型:user-用户,sp-应用服务主体

响应体示例

json

{
    "code": 0,
    "data": {
        "chat_id": "8417257",
        "content": {
            "text": {
                "content": "hel",
                "type": "plain"
            }
        },
        "ctime": 1744703111850,
        "id": "Q3iOi5TYS6tBSgS1",
        "mentions": [
            {
            "id": "string",
            "identity": {
            "company_id": "string",
            "id": "string",
            "type":"string" 
            },
            "type": "string"
            }
        ],
        "position": 22,
        "sender": {
            "app_id": "",
            "company_id": "648112656",
            "id": "100002594211",
            "type": "user"
        },
        "type": "text"
    },
    "msg": "success"
}