Updated on 2025-03-31 GMT+08:00

Pushing Messages (pushMsg)

Scenario

This interface is invoked to push a message (such as a connection, input status, session, transfer-to-manual, or disconnection message).

This interface can be used only when the message push function is enabled for the web channel and Verification Method is set to oAuth.

Method

POST

URI

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

Request Description

Table 1 Request header parameters

No.

Parameter

Type

Mandatory or Not

Description

1

x-app-key

String

Yes

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

2

Authorization

String

Yes

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

Table 2 Request body parameters

No.

Parameter

Type

Mandatory or Not

Description

1

messages

List [DownLinkMsg]

Yes

Messages and events

2

timestamp

Long

Yes

Sending time, which will be used to generate an authentication signature

Table 3 DownLinkMsg parameters

No.

Parameter

Type

Mandatory or Not

Description

1

channel

String

Yes

Message channel type, for example, WEB

2

isOfflineStatus

Boolean

No

Used by the client to determine whether a message can be sent in the next step.

When the user waiting times out, the AICC pushes the message.

If the asynchronous switch is turned on, the value is true.

If the asynchronous switch is turned off, the value is false.

3

content

String

Yes

Content of an MT message sent to a customer.

For a message whose controlType is CONNECT:

If mediaType is TEXT,

the value is the text content.

If mediaType is IMAGE, VIDEO, or AUDIO, the value is the resource ID. The client uses the file stream download API to obtain the resource.

If mediaType is LOCATE, the value is location information in the format of Latitude/Longitude/Description. If controlType is READ, the value is the read messageId array.

4

from

String

Yes

ID of the message sender. Channel ID.

5

mediaType

String

Yes

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

6

senderNickname

String

No

Nickname of the message sender

7

sourceType

String

Yes

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

8

controlType

String

Yes

Message control type. The options are CONNECT, CHAT, DISCONNECT, Trans2Agent, and READ.

9

timestamp

Long

Yes

Message sending timestamp

10

to

String

Yes

User ID

11

simQuestions

String

No

Similar questions

12

messageCode

String

No

Unique code used to identify the message agent that sends the message. The value can contain a maximum of 64 characters.

Response Description

  • Status code: 200
    Table 4 Response body parameters

    No.

    Parameter

    Type

    Description

    1

    resultCode

    String

    The value 0 indicates success. If the returned response status code is not 200 or the value of resultCode is not 0, the message fails to be pushed.

    2

    resultDesc

    String

    Defined by the developer.

  • 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

  • Request header
    Authorization:Bearer e******************************e
    x-app-key:e******************************0
    Content-Type:application/json
  • Request parameters
    //1connected
    {
        "timestamp": 1625898453913,
        "messages": [{
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "CHAT",
            "mediaType": "TEXT",
            "content": "The call is connected to an agent.",
            "simQuestions": null,
            "senderNickname": "SYSTEM",
            "timestamp": 1625898453913,
            "sourceType": "SYSTEM",
            "callId": null,
            "messageCode": null
        }]
    }
    //queuing
    {
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "CHAT",
            "mediaType": "TEXT",
            "content": "Queuing...",
            "simQuestions": null,
            "senderNickname": "SYSTEM",
            "timestamp": 1625898453913,
            "sourceType": "SYSTEM", 
            "messageCode": null
        }
    //disconnect because of agent
    {
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "DISCONNECT",
            "mediaType": null,
            "content": null,
            "simQuestions": null,
            "senderNickname": null,
            "timestamp": 1625898871961,
            "sourceType": "AGENT",
            "messageCode": null   
        }
    //disconnect because of timeout, and async switch is off
    {
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "DISCONNECT",
            "mediaType": null,
            "content": null,
            "simQuestions": null,
            "senderNickname": null,
            "timestamp": 1625898871961,
            "sourceType": "SYSTEM",
            "messageCode": null    
        }
    //disconnect because of timeout, and async switch is on
    {
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "DISCONNECT",
              "isOfflineStatus":true,
            "mediaType": "TEXT",
            "content": "{TIPS}",
            "simQuestions": null,
            "senderNickname": null,
            "timestamp": 1625898871961,
            "sourceType": "SYSTEM",
            "messageCode": null    
        }
    //read
    {
            "from": "202105284494222653",
            "channel": "WEB",
            "to": "44444444",
            "controlType": "READ",
            "mediaType": null,
            "content": "messageId1,messageId2",
            "simQuestions": null,
            "senderNickname": null,
            "timestamp": 1625898871961,
            "sourceType": "AGENT",
            "messageCode": null   
        }
  • Response parameters
    {
        "resultCode": "0",
        "resultDesc": "success."
    }