Skip to main content

Callback Before Sending Group Message

Description

The App backend can use this callback to view group messages sent by users in real-time. This includes:

  • Logging group messages in real-time (e.g., for logging or synchronization with other systems).
  • Intercepting user requests to send messages within the group.

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 business server must respond within the specified timeout period.

Scenarios that Trigger This Callback

  • A user sends a group message via the App client.
  • An App administrator sends a group message through the REST API.

Timing of Callback

  • Before OpenIMServer delivers the group message to group members.

Interface Description

Example Request URL

The CallbackCommand here is: callbackBeforeSendGroupMsgCommand

{WEBHOOK_ADDRESS}/callbackBeforeSendGroupMsgCommand?contenttype=json

Example Request Package

{
"sendID": "123456",
"callbackCommand": "callbackBeforeSendGroupMsgCommand",
"serverMsgID": "msg123",
"clientMsgID": "client123",
"operationID": "1646445464564",
"senderPlatformID": 1,
"senderNickname": "John",
"sessionType": 2,
"msgFrom": 1,
"contentType": 1,
"status": 0,
"sendTime": 1673048592000,
"createTime": 1673048592000,
"content": "Hello, this is a group message!",
"seq": 1,
"atUserList": ["user123", "user456"],
"faceURL": "http://example.com/user123.png",
"ex": "Extra data",
"groupID": "group567"
}

Request Package Field Descriptions

FieldTypeDescription
sendIDstringUnique identifier of the sender
callbackCommandstringCallback command for pre-group message send
serverMsgIDstringMessage ID generated by the server
clientMsgIDstringMessage ID generated by the client
operationIDstringUnique identifier for global traceability
senderPlatformIDint32Platform ID of the sender
senderNicknamestringNickname of the sender
sessionTypeint32Type of session
msgFromint32Message source: 1 for user, 2 for group
contentTypeint32Type of message content (1 indicates text)
statusint32Message status
sendTimeint64Timestamp of when the message was sent (ms)
createTimeint64Timestamp of when the message was created (ms)
contentstringMessage content
sequint32Sequence number of the message
atUserListstringList of group member IDs
faceURLstringURL of the sender's profile picture
exstringAdditional data field
groupIDstringUnique identifier of the group

Example Response Package

Approval to Send

This allows the user to send the group message.

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

Response Package Field Descriptions

FieldValueDescription
actionCode0Indicates whether the callback was successful. 0 means success.
errCode5001Custom error code in the range 5000-9999. Set if actionCode ≠ 0 or nextCode = 1.
errMsg"An error message"Simple error message for the custom error code.
errDlt"Detailed error information"Detailed error information for the custom error code.
nextCode1Next step directive. Set to 1 to stop further action if actionCode = 0.