Skip to main content

Callback Before Sending Group Chat Message

Functional Description

The App business server can operate on users' group chat messages in real-time through this callback, such as: real-time recording of sending group chat messages, intercepting users' illegal speech requests.

Precautions

  • To enable the callback, you must configure the callback URL and turn on the switch corresponding to this callback protocol. See the Callback Description document for configuration methods.
  • The callback direction is an HTTP/HTTPS POST request initiated by OpenIMServer to the App backend.
  • The APP business server must respond to this request within the timeout period.

Scenarios That May Trigger This Callback

  • App users send group chat messages through the client.
  • App administrators send group chat messages through REST API.

Timing of Callback

  • After OpenIMServer receives the group chat message sent by the user and before delivering the message to the target user.

Interface Description

Request URL Example

Here CallbackCommand is: callbackBeforeSendGroupMsgCommand

{WEBHOOK_ADDRESS}/callbackBeforeSendGroupMsgCommand?contenttype=json

Request Package Example

{
"sendID": "user123",
"callbackCommand": "callbackBeforeSendGroupMsgCommand",
"serverMsgID": "msg001",
"clientMsgID": "clientmsg001",
"operationID": "1646445464564",
"senderPlatformID": 1,
"senderNickname": "User123",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"sendTime": 1673048592000,
"createTime": 1673048592000,
"content": "Hello, this is a test message",
"seq": 1001,
"atUserList": ["user456", "user789"],
"faceURL": "http://example.com/path/to/user/image.png",
"ex": "Extra data",
"recvID": "user456"
}

Request Package Field Description

ObjectTypeDescription
sendIDstringUser ID of the sender
callbackCommandstringCallback command, here it is the callback before sending a group chat message
serverMsgIDstringMessage ID assigned by the server
clientMsgIDstringMessage ID assigned by the client
operationIDstringoperationID used for global link tracking
senderPlatformIDint32Platform ID of the sender
senderNicknamestringNickname of the sender
sessionTypeint32Session type
msgFromint32Message source
contentTypeint32Content type of the message
statusint32Status of the message
sendTimeint64Timestamp of message sending (milliseconds)
createTimeint64Timestamp of message creation (milliseconds)
contentstringMessage content
sequint32Message sequence number
atUserListarrayList of group member IDs, ignored for single chat
faceURLstringURL of the sender's avatar
exstringExtra data field
recvIDstringUser ID of the receiver

Response Package Example

Allow Sending

Allow users to send messages.

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

Response Package Field Description

FieldValueDescription
actionCode0Indicates whether the business system callback was executed correctly. 0 means the operation was successful.
errCode5001Custom error code, ranges from 5000-9999. Set when actionCode is not 0; set when nextCode is 1.
errMsg"Message"Simple error message corresponding to the custom error code.
errDlt"Detailed info"Detailed error information corresponding to the custom error code.
nextCode1Next execution instruction, 1 means refusing to continue execution, set when actionCode is 0.