Updated on 2023-09-27 GMT+08:00

Sending Messages: sendmessage

Description

The agent system can invoke this interface to send the message content entered by an agent to the channel application system. The channel application system then sends the message content to Internet users. Applications on the user side need to obtain the message content sent by the agent in polling mode.

Interface Method

The request method must be set to POST. This interface supports only the POST method.

URI

https://ip:port/agentgateway/resource/mediacall/{agentid}/sendmessage

In the URL, ip indicates the IP address of the CC-Gateway server, and port indicates the HTTPS port number of the CC-Gateway server.

No.

Parameter

Value Type

Mandatory (Yes/No)

Description

1

agentid

string

Yes

Agent ID. The value ranges from 101 to 59999.

Method Name in Logs

sendMessage

Request Description

  • Message header
    Table 1 Parameters in the request message header

    No.

    Parameter

    Value Type

    Mandatory (Yes/No)

    Description

    1

    Content-Type

    string

    Yes

    Coding mode of the message body. The default value is application/json; charset=UTF-8.

    2

    Guid

    string

    Yes

    GUID returned by the sign-in interface during static authentication (AUTHMODE is set to 1) or GUID returned by the polling event query interface during dynamic authentication (AUTHMODE is set to 2).

  • Message body
    Table 2 Parameters in the message body

    No.

    Parameter

    Value Type

    Mandatory (Yes/No)

    Description

    1

    callid

    string

    Yes

    Call ID.

    2

    userid

    string

    No

    User number.

    3

    data

    Object

    Yes

    If the value is a string, it indicates the text content of the message to be sent.

    When platform encryption is selected during CC-Gateway installation (that is, the MULTIMEDIA_SECMODE parameter in /home/elpis/tomcat/webapps/agentgateway/WEB-INF/config/basic.properties is set to 1), the maximum size of the message content is 1.9 KB.

    When business-side encryption is selected during CC-Gateway installation

    (that is, the MULTIMEDIA_SECMODE parameter in /home/elpis/tomcat/webapps/agentgateway/WEB-INF/config/basic.properties is set to 0), the maximum size of the message content is 3.8 KB.

    In the public cloud scenario, the value is a string in JSON format. Table 3 describes the JSON format.

    Table 3 JSON format in data

    No.

    Parameter

    Value Type

    Mandatory (Yes/No)

    Description

    1

    from

    string

    Yes

    Channel ID, which is the value of Configuration ID of the channel added by the enterprise on the Configuration Center > Access Configuration > Channel Configuration page of the tenant space.

    2

    to

    string

    Yes

    User number. The value is specified by the enterprise and is generally the recipient ID.

    3

    channel

    string

    Yes

    Message channel. The options are as follows:

    • WEB
    • WECHAT
    • TWITTER
    • FACEBOOK
    • 5G
    • EMAIL
    • VOICE
    • LINE
    • WHATSAPP
    • SMS
    • INSTAGRAM
    • TELEGRAM

    4

    controlType

    string

    Yes

    Control type. The value is fixed to CHAT.

    5

    mediaType

    string

    Yes

    Media type.

    The options are as follows:

    • TEXT: text
    • IMAGE: image
    • AUDIO: audio
    • VIDEO: video
    • LOCATE: location
    • EMOTICONS: emoji
    • CARD: card
    • MULTICARD: carousel card
    • EMAIL: email
    • WHATSAPPTEMPLATE: WhatsApp template
    • RICHTEXT: rich text
    • WEBCARD: web card message
    • SMSTEMPLATE: SMS template message
    • LOCATION: location (Telegram)
    • DOCUMENT: document
    • COBROWSESITE: co-browsing URL

    6

    messageCode

    string

    Yes

    Unique code of a message, for example, the UUID.

    7

    mediaFileType

    string

    No

    Media file type.

    • If mediaType is IMAGE, the options are jpg, png, and jpeg.
    • If mediaType is AUDIO, the options are mp3, aac, m4a, and mp4.
    • If mediaType is EMOTICONS, the option is gif.
    • If mediaType is DOCUMENT, the options are doc, docx, pdf, zip, and RTF.

    8

    senderNickname

    string

    Yes

    Agent nickname.

    The value is specified by the enterprise.

    9

    senderAvatar

    string

    Yes

    Agent avatar. The value is specified by the enterprise.

    10

    sendTime

    string

    Yes

    Sending timestamp.

    11

    content

    string

    Yes

    Message content. Directly enter the content of the message to be sent, or enter a message format that can be parsed by the third-party system.

    12

    contentType

    string

    No

    Message type.

    • If this parameter is set to 1, the file to be sent is a local file selected by the agent.
    • If this parameter is not passed or is set to 0, the file to be sent is a multimedia library file instead of a local file.

      In this case, the file must be uploaded in Configuration Center > Resource Management > Online Chat Multimedia Library of the tenant space in advance.

    13

    userId

    string

    Yes

    User ID. The value is defined by the enterprise and can be the same as that of to.

Response Description

Table 4 Parameters in the message body

No.

Parameter

Value Type

Description

1

retcode

string

Message sending result.

  • 0: success
  • Other values: failure

2

message

string

Description.

Triggered Event

None

Error Code

  • 106-001
  • 106-002
  • 106-007
  • 106-011
  • 106-013
  • 106-014

Example

  • Message header
    Content-Type:application/json; charset=UTF-8
    Guid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.AgentGateway1
  • Request parameter
    Public cloud scenario:
    {
        "callid": "1552524689-16797284",
        "userid": "88880043",
        "data": "{\"from\":\"202301032048582419\",\"to\":\"1672709693442874044\",\"channel\":\"WEB\",\"controlType\":\"CHAT\",\"mediaType\":\"TEXT\",\"messageCode\":\"b72d414f-97ca-4897-bc9f-a727ad92ff12\",\"content\":\"<p>Message sent by the agent</p>\",\"senderNickname\":\"Agent\",\"senderAvatar\":\"DefaultAvatar\",\"sendTime\":1678109503317,\"userId\":\"1672709693442874044\"}",
        "content": "Message sent by the agent"
    }

  • Response parameter
    {
        "message": "success",
        "retcode": "0"
    }