Skip to main content

Callback For Modifying Message Content

Functional Description

The business server can modify the message content through this callback, such as modifying and replacing sensitive words.

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

  • Before users perform message sending through the client or APP administrators through REST API

Timing of Callback

  • Before sending a message.

Interface Description

Request URL Example

Here CallbackCommand is: callbackBeforeMsgModifyCommand

{WEBHOOK_ADDRESS}/callbackBeforeMsgModifyCommand?contenttype=json

Request Package Example

{
"sendID": "sender123",
"callbackCommand": "callbackBeforeMsgModifyCommand",
"serverMsgID": "serverMsg123",
"clientMsgID": "clientMsg123",
"operationID": "1646445464564",
"senderPlatformID": 1,
"senderNickname": "Sender",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"sendTime": 1673048592000,
"createTime": 1673048592000,
"content": "Hello, World!",
"seq": 123,
"atUserList": ["user123", "user456"],
"faceURL": "http://example.com/sender_face.png",
"ex": "Extra data"
}

Request Package Field Description

ObjectTypeDescription
sendIDstringUnique identifier of the sender
callbackCommandstringCallback command, here it is the message modification command callback
serverMsgIDstringMessage ID generated by the server
clientMsgIDstringMessage ID generated by the client
operationIDstringoperationID used for global link tracking
senderPlatformIDint32Platform ID of the sender
senderNicknamestringNickname of the sender
sessionTypeint32Session type, indicating single chat or group chat
msgFromint32Message source, indicating whether the message is sent or received
contentTypeint32Content type of the message
statusint32Status of the message
sendTimeint64Timestamp of message sending (milliseconds)
createTimeint64Timestamp of message creation (milliseconds)
contentstringContent of the message
sequint32Sequence number of the message
atUserList[]stringList of group member IDs
faceURLstringAvatar URL of the sender
exstringExtra data field

Response Package Example

Allow Modification

Allow modification to the message.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0,
"content": "Modified content",
"recvID": "receiver123",
"groupID": "group123",
"clientMsgID": "clientMsg456",
"serverMsgID": "serverMsg456",
"senderPlatformID": 1,
"senderNickname": "ModifiedSender",
"senderFaceURL": "http://example.com/modified_sender_face.png",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"options": {
"option1": true,
"option2": false
},
"offlinePushInfo": {
"title": "Modified Notification",
"content": "Modified Content",
"pushFlag": 1,
"sound": "default",
"badge": 1
},
"atUserIDList": ["user789", "user101112"],
"msgDataList": [65, 66, 67],
"attachedInfo": "Modified Info",
"ex": "Modified Extra data"
}

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"An error message"Simple error message corresponding to the custom error code.
errDlt"Detailed error information"Detailed error information corresponding to the custom error code.
nextCode1Next execution instruction, 1 means refusing to continue execution, set when actionCode is 0.
content*stringModified message content.
recvID*stringUser ID receiving the message.
groupID*stringUnique identifier of the group.
clientMsgID*stringMessage ID generated by the client.
serverMsgID*stringMessage ID generated by the server.
senderPlatformID*int32Platform ID of the sender.
senderNickname*stringNickname of the sender.
senderFaceURL*stringAvatar URL of the sender.
sessionType*int32Session type.
msgFrom*int32Message source.
contentType*int32Content type of the message.
status*int32Status of the message.
options*map[string]boolModified message options.
offlinePushInfo*OfflinePushInfoModified offline push info.
atUserIDList*[]stringList of group member IDs.
msgDataList*[]byteModified message data list.
attachedInfo*stringModified attached info.
ex*stringModified extra data field.