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
Field | Type | Description |
---|---|---|
sendID | string | Unique identifier of the sender |
callbackCommand | string | Callback command for pre-group message send |
serverMsgID | string | Message ID generated by the server |
clientMsgID | string | Message ID generated by the client |
operationID | string | Unique identifier for global traceability |
senderPlatformID | int32 | Platform ID of the sender |
senderNickname | string | Nickname of the sender |
sessionType | int32 | Type of session |
msgFrom | int32 | Message source: 1 for user, 2 for group |
contentType | int32 | Type of message content (1 indicates text) |
status | int32 | Message status |
sendTime | int64 | Timestamp of when the message was sent (ms) |
createTime | int64 | Timestamp of when the message was created (ms) |
content | string | Message content |
seq | uint32 | Sequence number of the message |
atUserList | string | List of group member IDs |
faceURL | string | URL of the sender's profile picture |
ex | string | Additional data field |
groupID | string | Unique 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
Field | Value | Description |
---|---|---|
actionCode | 0 | Indicates whether the callback was successful. 0 means success. |
errCode | 5001 | Custom 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. |
nextCode | 1 | Next step directive. Set to 1 to stop further action if actionCode = 0 . |