logo
开发者文档
搜索
获取对话的消息明细

获取对话的消息明细

根据入参的 conversation_id ,获取该条对话内的所有消息内容明细,包含message_id、用户问题、消息类型、消息内容、消息产生时间等信息。

请求方式

GET

调用地址

https://api-${endpoint}.gptbots.ai/v2/messages

调用验证

详情参见 API 概述的鉴权方式说明。

请求

请求示例

curl -X GET 'https://api-${endpoint}.gptbots.ai/v2/messages?conversation_id=xxxxxx&page=1&page_size=100' \ -H 'Authorization: Bearer ${API Key}'
                      
                      curl -X GET 'https://api-${endpoint}.gptbots.ai/v2/messages?conversation_id=xxxxxx&page=1&page_size=100' \
-H 'Authorization: Bearer ${API Key}'

                    
此代码块在浮窗中显示

请求头

字段 类型 描述
Authorization Bearer ${API Key} 使用Authorization: Bearer ${API Key}进行调用验证,请在 API 密钥页面获取密钥作为API Key

请求参数

字段 类型 必填 描述
conversation_id string 对话标识符。
page int 页数,表示你想请求第几页的数据。
page_size int 每页的数据量,表示你希望每页返回多少条数据,最多 100 条。

响应

响应示例

{ "total": 2, "conversation_content": [ { "message_id": "645dd86906931c4a9e0ffb1f", "parent_message_id": "545dd86906931c4a9e0ffb1f", "create_time": 1683871849906, "feedback": "POSITIVE", "role": "user", "content": [ { "branch_content": [ { "type": "text", "text": "I have uploaded 2 image files, please OCR and return 2 json records." }, { "type": "image", "image": [ { "url": "https://gptbots.ai/example.png", "format": "jpeg", "name": "TAXI1", "size": 1024 }, { "url": "https://gptbots.ai/example.png", "format": "png", "name": "TAXI2", "size": 1024 } ] }, { "type": "audio", "audio": [ { "url": "https://gptbots.ai/example.mp3", "format": "mp3", "name": "example1 audio", "size": 1024 } ] }, { "type": "document", "document": [ { "url": "https://gptbots.ai/example.pdf", "format": "pdf", "name": "example pdf", "size": 1024 } ] } ] } ] }, { "message_id": "745dd86906931c4a9e0ffb1f", "parent_message_id": "645dd86906931c4a9e0ffb1f", "create_time": 1683871849906, "feedback": "POSITIVE", "role": "assistant", "content": [ { "from_component_branch": "1", "branch_content": [ { "type": "text", "text": "Hi, is there anything I can help you?", }, { "type": "audio", "audio": [ { "url": "http://gptbots.ai/example.mp3", "transcript": "音频所转录的文字内容" } ] }, ] }, { "from_component_branch": "2", "branch_content": [ { "type": "document", "document": [ { "url": "https://gptbots.ai/example.pdf", "format": "pdf", "name": "example pdf" } ] }, { "type": "image", "image": [ { "url": "https://gptbots.ai/example.png", "format": "png", "name": "TAXI2" } ] } ] } ] } ] }
                      
                      {
  "total": 2,
  "conversation_content": [
    {
      "message_id": "645dd86906931c4a9e0ffb1f",
      "parent_message_id": "545dd86906931c4a9e0ffb1f",
      "create_time": 1683871849906,
      "feedback": "POSITIVE",
      "role": "user",
      "content": [
        {
            "branch_content": [
                {
                    "type": "text",
                    "text": "I have uploaded 2 image files, please OCR and return 2 json records."
                },
                {
                    "type": "image",
                    "image": [
                        {
                            "url": "https://gptbots.ai/example.png",
                            "format": "jpeg",
                            "name": "TAXI1",
                            "size": 1024
                        },
                        {
                            "url": "https://gptbots.ai/example.png",
                            "format": "png",
                            "name": "TAXI2",
                            "size": 1024
                        }
                    ]
                },
                {
                    "type": "audio",
                    "audio": [
                        {
                            "url": "https://gptbots.ai/example.mp3",
                            "format": "mp3",
                            "name": "example1 audio",
                            "size": 1024
                        }
                    ]
                },
                {
                    "type": "document",
                    "document": [
                        {
                            "url": "https://gptbots.ai/example.pdf",
                            "format": "pdf",
                            "name": "example pdf",
                            "size": 1024
                        }
                    ]
                }
            ]
        }
      ]
    },
    {
      "message_id": "745dd86906931c4a9e0ffb1f",
      "parent_message_id": "645dd86906931c4a9e0ffb1f",
      "create_time": 1683871849906,
      "feedback": "POSITIVE",
      "role": "assistant",
      "content": [
        {
            "from_component_branch": "1",
            "branch_content": [
                  {
                    "type": "text",
                    "text": "Hi, is there anything I can help you?",
                  },
                  {
                    "type": "audio",
                    "audio": [
                    {
                        "url": "http://gptbots.ai/example.mp3",
                        "transcript": "音频所转录的文字内容"
                    }
                    ]
                  },
            ]
        },
        {
            "from_component_branch": "2",
            "branch_content": [
                  {
                    "type": "document",
                    "document": [
                        {
                            "url": "https://gptbots.ai/example.pdf",
                            "format": "pdf",
                            "name": "example pdf"
                        }
                    ]
                  },
                  {
                    "type": "image",
                    "image": [
                        {
                            "url": "https://gptbots.ai/example.png",
                            "format": "png",
                            "name": "TAXI2"
                        }
                    ]
                  }
            ]
        }
      ]
    }
  ]
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 描述
total string 本对话中的消息总数。
conversation_content JSON Array 消息详情。
message_id string 消息的唯一标识。
parent_message_id string 本消息的父消息的唯一标识。
create_time long 这条消息产生的时间戳。
feedback string 用户对这条消息的反馈,取值:POSITIVE、NEGATIVE。若无反馈则不会返回该字段。
role string 消息角色,取值:user、assistant。
content JSON Array 消息内容。
from_component_branch string 消息来源的组件分支ID,当用户发送消息和普通Agent该字段为空
branch_content JSON Array 消息分支内容。
type string 消息内容类型,取值:text、image、audio、document、video、file。
text string 文本消息内容。
image JSON Array 图片消息内容。
audio JSON Array 音频消息内容。
document JSON Array 文档消息内容。
video JSON Array 视频消息内容。
file JSON Array 文件消息内容。

失败响应

字段 类型 描述
code int 错误码。
message string 错误详情。

错误码

Code Message
40000 参数错误
40005 分页参数不能大于实际数量
40127 开发者鉴权失败
40356 会话不存在
20059 Agent 已删除