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
| Field | Type | Description |
|---|---|---|
| sendID | string | Sender's user ID |
| callbackCommand | string | Callback command, here used for the callback after sending a single chat message |
| serverMsgID | string | Server-generated message ID |
| clientMsgID | string | Client-generated message ID |
| operationID | string | Used for global tracking |
| senderPlatformID | int32 | Sender's platform ID |
| senderNickname | string | Sender's nickname |
| sessionType | int32 | Session type, 1: single chat, 2: group chat, 4: system notification |
| msgFrom | int32 | Message source, 100: user sent, 200: admin or system notification |
| contentType | int32 | Content type of the message, 101: text, 102: image, 103: voice, etc. |
| status | int32 | Message status, 1: sent successfully, 2: failed |
| sendTime | int64 | Timestamp when the message was sent (milliseconds) |
| createTime | int64 | Timestamp when the message was created (milliseconds) |
| content | string | Content of the message |
| seq | uint32 | Message sequence number |
| atUserList | string | List of group member IDs, ignore for single chat |
| faceURL | string | Sender's avatar URL |
| ex | string | Extra data field |
| recvID | string | Receiver'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
| Field | Value | Description |
|---|---|---|
| actionCode | 0 | Indicates whether the callback was successfully executed. 0 means success. |
| errCode | 0 | Custom 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 |
| nextCode | 1 | Next step directive; 1 to halt further action if actionCode = 0 |