Skip to main content

Callback After Sending Single Chat Message

Description

The App backend can use this callback to perform actions on single chat messages, such as:

  • Logging single chat messages in real-time (for logs or synchronization with other systems).
  • Performing data analysis on single chat messages (e.g., counting users or messages).

Important Notes

  • To enable this callback, configure the callback URL and activate the corresponding protocol switch. For configuration details, see the Callback Introduction document.
  • The callback direction is from OpenIMServer to the App backend as an HTTP/HTTPS POST request.
  • The App backend must respond to this request within the specified timeout.

Scenarios that Trigger This Callback

  • A user sends a single chat message through the client.
  • An administrator sends a single chat message via the REST API.

Timing of Callback

  • After OpenIMServer receives the user’s single chat message and distributes it to the target user.

Interface Description

Example Request URL

The CallbackCommand here is: callbackAfterSendSingleMsgCommand

{WEBHOOK_ADDRESS}/callbackAfterSendSingleMsgCommand?contenttype=json

Example Request Package

{
"sendID": "user123",
"callbackCommand": "callbackAfterSendSingleMsgCommand",
"serverMsgID": "serverMsg123",
"clientMsgID": "clientMsg123",
"operationID": "1646445464564",
"senderPlatformID": 1,
"senderNickname": "John Doe",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"sendTime": 1673048592000,
"createTime": 1673048592000,
"content": "Hello, how are you?",
"seq": 1,
"atUserList": ["user456", "user789"],
"faceURL": "http://example.com/path/to/face/image.png",
"ex": "Extra data",
"recvID": "user456"
}

Request Package Field Descriptions

FieldTypeDescription
sendIDstringSender's user ID
callbackCommandstringCallback command, here used for the callback after sending a single chat message
serverMsgIDstringServer-generated message ID
clientMsgIDstringClient-generated message ID
operationIDstringUsed for global tracking
senderPlatformIDint32Sender's platform ID
senderNicknamestringSender's nickname
sessionTypeint32Session type, 1: single chat, 2: group chat, 4: system notification
msgFromint32Message source, 100: user sent, 200: admin or system notification
contentTypeint32Content type of the message, 101: text, 102: image, 103: voice, etc.
statusint32Message status, 1: sent successfully, 2: failed
sendTimeint64Timestamp when the message was sent (milliseconds)
createTimeint64Timestamp when the message was created (milliseconds)
contentstringContent of the message
sequint32Message sequence number
atUserListstringList of group member IDs, ignore for single chat
faceURLstringSender's avatar URL
exstringExtra data field
recvIDstringReceiver's user ID

Example Response Package

Success Response

The App backend sends a callback response after synchronizing data.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0
}

Response Package Field Descriptions

FieldValueDescription
actionCode0Indicates whether the callback was successfully executed. 0 means success.
errCode0Custom error code, set to 0 to ignore the callback result
errMsg"An error message"Simple error message for the custom error code
errDlt"Detailed error information"Detailed error information
nextCode1Next step directive; 1 to halt further action if actionCode = 0