Help Center/ Cognitive Engagement Center/ API Reference/ Web Client Access Interface Reference/ Proactively Polling Messages Sent by Agents (poll)
Updated on 2023-12-19 GMT+08:00

Proactively Polling Messages Sent by Agents (poll)

Scenario

This interface is invoked to proactively poll messages sent by agents to users.

If no message is found, check whether the send interface is invoked to set up a connection (CONNECT).

If the send interface is not invoked during a session, the session is automatically released when the default session duration (configured on the CCUCS backend) is exceeded.

Method

GET

URI

https://Domain name/apiaccess/ccmessaging/poll (For example, the domain name is service.besclouds.com.)

Request Description

Table 1 Query parameters

No.

Parameter

Type

Mandatory or Not

Description

1

receiverId

String

Yes

Recipient ID, that is, userId in applyToken

2

channel

String

Yes

Recipient channel type. The default value WEB must be used.

3

isNeedRead

String

No

Whether to read the message indicating that the agent has read the user message. The value true indicates that the message is required. Other values or an empty value indicate that the message is not required.

Table 2 Request header parameters

No.

Parameter

Type

Mandatory or Not

Description

1

ccmessaging-token

String

Yes

  • Value of token returned by the applyToken interface
  • Value of ccmessaging-token returned in the interface response header during a session

2

x-app-key

String

Yes

App key, which is the user ID and is configured on the API Fabric

3

Authorization

String

Yes

Authentication field. The format is Bearer (space){Value of AccessToken returned by the tokenByAkSk interface}. (A space is required after Bearer.)

Response Description

  • Status code: 200
    Table 3 pollRsp parameters

    No.

    Parameter

    Type

    Mandatory or Not

    Description

    1.1

    resultDesc

    String

    No

    Result description

    If the operation is successful, the description is query user messages success. If the operation fails, no description is returned.

    1.2

    downlinkMessages

    downLIinkMsgArr

    Yes

    Array of messages sent to users

    1.3

    resultCode

    String

    Yes

    Result code of the message received by the client. The value 0 indicates success, and other values indicate failure.

    Table 4 downLIinkMsgArr parameters

    No.

    Parameter

    Type

    Mandatory or Not

    Description

    1.1

    channel

    String

    Yes

    Message channel type. Currently, the value is fixed to WEB, indicating the access from the web channel.

    1.2

    content

    String

    Yes

    Content of the MT message sent to a customer. The value can contain a maximum of 500 characters.

    The value varies according to the media type.

    For a multimedia library file, the value is the multimedia library file ID.

    For a local file, the value is the OBS key.

    1.3

    from

    String

    Yes

    Message sender ID. Generally, the value is the same as that of Configuration ID of the channel in the AICC.

    1.4

    mediaType

    String

    Yes

    Message media type. The options are TEXT, IMAGE, VIDEO, AUDIO, LOCATE, and DOCUMENT.

    1.5

    senderNickname

    String

    No

    Nickname configured when an agent signs in or the robot is enabled. If the message is a system message, the nickname is system.

    1.6

    sourceType

    String

    Yes

    Message sender. The options are AGENT, ROBOT, and SYSTEM.

    1.7

    timestamp

    String

    No

    Message sending timestamp

    1.8

    to

    String

    Yes

    Message recipient ID. Generally, the value is that of userId sent by the enterprise client

    1.9

    simQuestions

    String

    Yes

    Similar question content

    1.10

    isOfflineStatus

    Boolean

    No

    This parameter is used by the client to determine whether a message can be sent in the next step.

    1.11

    messageCode

    String

    No

    Unique message code, which is used to identify the message for canceling or deleting an action

    1.12

    interIdx

    String

    No

    Number of interaction times. The value is the same as that of inter_idx returned by the ODFS in the previous time.

    1.13

    contentType

    String

    No

    If the file is a multimedia library file, the return value is null.

    If the file is a local file, the value is 1.

    1.14

    mediaFileType

    String

    No

    Multimedia file type. The options are jpg, png, bpm, mp3, aac, mp4, txt, csv, richtext, doc, docx, pdf, and zip.

    1.15

    controlType

    String

    No

    The options are CHAT, DISCONNECT, and READ.

  • Status code: 400

    Incorrect request. Check the request path and parameters.

  • Status code: 401

    Unauthorized operation. 1. Check whether you have purchased related services. 2. Contact customer service to check the status of your account.

  • Status code: 404

    The requested content is not found. Check the request path.

  • Status code: 500

    Business failure. Check the values of parameters in the request.

Error Codes

None

Example

  • Scenario: example messages

    URL: {Domain address}/apiaccess/ccmessaging/poll?receiverId=XXXXXXXXXXXXXXXXXXXXXXXX&channel=WEB

    Request header:

    ccmessaging-token: XXXXXXXXX

    Response parameters:

    {
    	"resultCode": "0",
    	"resultDesc": "query user messages success.",
    	"downlinkMessages": [{
    		"from": "1011577355744904195",
    		"channel": "WEB",
    		"to": "session_fixed_user_fixed",
    		"controlType": "CHAT",
    		"mediaType": "TEXT",
    		"content": "Welcome",
    		"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": "Switch to manual service",
    		"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": "Agent connected",
    		"simQuestions": null,
    		"senderNickname": "system",
    		"senderAvatar": null,
    		"timestamp": 1619590484115,
    		"sourceType": "SYSTEM",
    		"callId": null,
    		"robotGender": null
    	}]
    }
    In the multimedia library file scenario:
    {
        "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": "png", 
                "contentType": null, 
                "interIdx": null, 
                "timestamp": 1648102235191
            }
        ], 
        "resultCode": "0", 
        "resultDesc": "query user messages success."
    }
    
    In the scenario of sending local files:
    {
        "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."
    }