更新时间:2025-11-13 GMT+08:00
分享

查询消息

接口功能

用户查询收到的消息

使用说明

  • 前提条件

    正确创建web渠道配置。

接口原型

表1 接口原型说明

请求方法

GET

请求URL

https://ip:port/service-cloud/rest/webadapter/v1/webadapterfacade/getMessageForWebChannel

其中,ip:port为对外暴露的nslb的ip和port

表2 请求Headers参数说明

参数名称

选取原则

参数类型

默认值

说明

Content-Type

必选

String

固定填 application/json; charset=UTF-8。

Cookie

必选

String

集成页面的时候,ccmessaging通过请求响应,将ccmessaging-token写到集成页面浏览器的Cookie中。单独调用时需确保请求头的Cookie中含有ccmessaging-token=xxx,xxx为ccmessaging-token值。

请求参数

无。

响应参数

参数名称

选取原则

参数类型

说明

resultCode

必选

String

接口响应码,0:成功

resultDesc

必选

String

接口描述

downlinkMessages

可选

Array

消息结构体

表3 downlinkMessages 消息结构体参数

参数名称

选取原则

参数类型

说明

channel

True

string

消息渠道类型,当前固定为WEB,表示WEB渠道接入。

content

True

string

发送给客户下行消息内容,最多500个字符。

根据mediaType不同,content有不同的格式。

如果是多媒体库文件,为多媒体库文件ID;

如果是本地文件,为obskey。

from

True

string

消息发送方的id,一般为AICC侧渠道的“配置ID”。

mediaType

True

string

消息媒体类型,如文本类型(TEXT)、图片(IMAGE)、视频(VIDEO)、语音(AUDIO)、位置(LOCATE)、文档(DOCUMENT)

senderNickname

False

string

座席侧或机器人开启时配置的昵称。如果是系统消息,则返回“系统”(中文租间)或“system”(英文租间)。

sourceType

True

string

消息发送方来源,如人工座席(AGENT)、机器人(ROBOT)、系统(SYSTEM)

timestamp

False

string

消息发送时间戳

to

True

string

消息接收方id,通常为企业侧客户端发送的userId。

simQuestions

True

string

相似问内容

isOfflineStatus

False

boolean

用于客户端判断下一步是否可以发送消息。

messageCode

False

string

消息唯一编码,用来识别撤销或删除动作操作的消息

interIdx

False

string

交互次数,直接取上一次ODFS返回的inter_idx值即可

contentType

False

string

如果是多媒体库文件,返回值为null;

如果是本地文件,为"1"。

mediaFileType

False

string

如果是多媒体库文件,返回值为null;

如果是本地文件,返回值为多媒体文件类型。

controlType

False

string

如聊天(CHAT),断开连接(DISCONNECT),READ(已读)

接口示例

  • 请求示例
    GET /service-cloud/rest/webadapter/v1/webadapterfacade/getMessageForWebChannel
    
    host: 10.10.10.2:18446
    connection: Keep-Alive
    x-forwarded-for: 10.10.10.3, 10.10.10.4
    x-real-ip: 10.10.10.5
    content-length: 401
    remote-host: 10.10.10.6
    user-agent: java/socket
    content-type: application/json; charset=utf-8
    cookie: JSESSION*****#*#*****3
    ccmessaging-token:********
    accept: */*
  • 响应示例
    {
    	"resultCode": "0",
    	"resultDesc": "query user messages success.",
    	"downlinkMessages": [{
    		"from": "1011577355744904195",
    		"channel": "WEB",
    		"to": "session_fixed_user_fixed",
    		"controlType": "CHAT",
    		"mediaType": "TEXT",
    		"content": "欢迎欢迎,热列欢迎",
    		"simQuestions": null,
    		"senderNickname": "test",
    		"senderAvatar": "1",
    		"timestamp": 1619590480756,
    		"sourceType": "ROBOT",
    		"callId": null,
    		"robotGender": "MALE"
    	}, {
    		"from": "1011577355744904195",
    		"channel": "WEB",
    		"to": "session_fixed_user_fixed",
    		"controlType": "CHAT",
    		"mediaType": "TEXT",
    		"content": "转人工",
    		"simQuestions": null,
    		"senderNickname": "test",
    		"senderAvatar": "1",
    		"timestamp": 1619590482098,
    		"sourceType": "ROBOT",
    		"callId": null,
    		"robotGender": "MALE"
    	}, {
    		"from": "1011577355744904195",
    		"channel": "WEB",
    		"to": "session_fixed_user_fixed",
    		"controlType": "CHAT",
    		"mediaType": "TEXT",
    		"content": "已接通座席。",
    		"simQuestions": null,
    		"senderNickname": "系统",
    		"senderAvatar": null,
    		"timestamp": 1619590484115,
    		"sourceType": "SYSTEM",
    		"callId": null,
    		"robotGender": null
    	}]
    }
    多媒体库文件场景下:
    {
        "downlinkMessages": [
            {
                "callId": null, 
                "simQuestions": null, 
                "senderNickname": "agent", 
                "handlerType": null, 
                "isOfflineStatus": null, 
                "channel": "WEB", 
                "senderAvatar": "", 
                "robotGender": null, 
                "mediaType": "IMAGE", 
                "associationContentId": null, 
                "content": "1179725658739559425", 
                "receiveTime": null, 
                "controlType": "CHAT", 
                "sourceType": "AGENT", 
                "queueFlag": null, 
                "messageCode": "1e1f2bf7-fd6e-4471-a45d-2b43d1eb6272", 
                "from": "202201077401331370", 
                "to": "1642643982282972758", 
                "mediaFileType": null, 
                "contentType": null, 
                "interIdx": null, 
                "timestamp": 1648102235191
            }
        ], 
        "resultCode": "0", 
        "resultDesc": "query user messages success."
    }
    
    发送本地文件场景下:
    {
        "downlinkMessages": [
            {
                "callId": null, 
                "simQuestions": null, 
                "senderNickname": "agent", 
                "handlerType": null, 
                "isOfflineStatus": null, 
                "channel": "WEB", 
                "senderAvatar": "", 
                "robotGender": null, 
                "mediaType": "IMAGE", 
                "associationContentId": null, 
                "content": "878e7d9a-8e2f-4893-8b54-352f8ecbf86c", 
                "receiveTime": null, 
                "controlType": "CHAT", 
                "sourceType": "AGENT", 
                "queueFlag": null, 
                "messageCode": "9374d9c4-b8ee-4035-aab9-ad5ceddbb856", 
                "from": "202201077401331370", 
                "to": "1642643982282972758", 
                "mediaFileType": "png", 
                "contentType": "1", 
                "interIdx": null, 
                "timestamp": 1648102054235
            }
        ], 
        "resultCode": "0", 
        "resultDesc": "query user messages success."
    }

相关文档