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", "source_page": "https://your-site.com/pricing", "sentiment_label": "neutral", "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", "source_page": "https://your-site.com/pricing", "sentiment_label": "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" } ] } ] } ] } ], "audio_record_url": "https://gptbots.ai/record/full-call.mp3", "user_sender": { "channel_type": "Channel::Whatsapp", "user_id": "+66812345678", "profile": { "name": "John Doe" }, "additional_attributes": {}, "provider": "whatsapp_cloud", "phone_number": "+66900000000" } }
                      
                      {
  "total": 2,
  "conversation_content": [
    {
      "message_id": "645dd86906931c4a9e0ffb1f",
      "parent_message_id": "545dd86906931c4a9e0ffb1f",
      "create_time": 1683871849906,
      "feedback": "POSITIVE",
      "source_page": "https://your-site.com/pricing",
      "sentiment_label": "neutral",
      "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",
      "source_page": "https://your-site.com/pricing",
      "sentiment_label": "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"
                        }
                    ]
                  }
            ]
        }
      ]
    }
  ],
  "audio_record_url": "https://gptbots.ai/record/full-call.mp3",
  "user_sender": {
    "channel_type": "Channel::Whatsapp",
    "user_id": "+66812345678",
    "profile": { "name": "John Doe" },
    "additional_attributes": {},
    "provider": "whatsapp_cloud",
    "phone_number": "+66900000000"
  }
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 描述
total string 本对话中的消息总数。
conversation_content JSON Array 消息详情。
message_id string 消息的唯一标识。
parent_message_id string 本消息的父消息的唯一标识。
create_time long 这条消息产生的时间戳。
feedback string 用户对这条消息的反馈,取值:POSITIVE、NEGATIVE。若无反馈则不会返回该字段。
source_page string 该条消息的来源网页,即消息产生时用户所在的网页 URL。目前仅 Livechat 渠道支持传输该字段,当对话来源不为 Livechat 时,该值为空。
sentiment_label string 消息情绪标签,与对话日志中的情绪字段对齐。
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 文件消息内容。
audio_record_url string 语音通话整通录音文件 URL,仅语音(Audio)Agent 有;无录音时不返回该字段。
user_sender JSON Object 用户渠道信息。三方渠道接入(目前 LiveDesk)时于对话入站落库,取自渠道 webhook 的发送者渠道信息(支持 WhatsApp / LINE 等渠道),与流程变量 ld_user_sender 同源。未采集到时不返回该字段;常见字段见下表。

user_sender 常见字段

该对象为来源渠道透传的用户渠道信息,字段随渠道而定,以下为常见字段,实际以渠道返回为准。

字段 类型 描述
channel_type string 渠道类型,如 Channel::Whatsapp、Channel::Line、Channel::Webwidget 等。
user_id string 渠道侧用户标识:WhatsApp 为手机号/wa_id,LINE 为 userId,其他渠道为 identifier。
profile JSON Object 用户资料(如 name)。
additional_attributes JSON Object 渠道附加属性。
provider string 渠道 provider。
phone_number string 渠道侧配置的手机号。

失败响应

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

错误码

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