Skip to main content

Callback Before Creating Single Chat Conversation

Functional Description

The App business server can operate on the user's single chat conversation creation in real-time through this callback, such as: real-time recording of single chat conversation creation, allowing the creation of a single chat conversation.

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 create single chat conversations through the client.

Timing of Callback

  • After OpenIMServer receives that a user is creating a single chat conversation and before delivering the information to the target user.

Interface Description

Request URL Example

Here CallbackCommand is: callbackBeforeCreateSingleChatConversationsCommand

{WEBHOOK_ADDRESS}/callbackBeforeCreateSingleChatConversationsCommand?contenttype=json

Request Package Example

{
"callbackCommand": "callbackBeforeCreateSingleChatConversationsCommand",
"ownerUserId": "123228123",
"conversationId": "si_123228123_622925731",
"conversationType": 1,
"userId": "622925731",
"recvMsgOpt": 0,
"isPinned": false,
"isPrivateChat": false,
"burnDuration": 0,
"groupAtType": 0,
"attachedInfo": "",
"ex": "Extra conversation data"
}

Request Package Field Description

ObjectTypeDescription
callbackCommandstringCallback command, here it is the callback before creating a single chat conversation
ownerUserIdstringThe user Id of the conversation owner
conversationIdstringConversation Id
conversationTypeintConversation type, 1 is single chat, 3 is group chat
userIdstringConversation user Id, this field takes effect when the conversation type is 1
recvMsgOptintMessage receiving options, 0 for normal receipt; 1 for no message receipt; 2 for receiving messages without notification
isPinnedbooleanIs the conversation pinned
isPrivateChatbooleanIs burn after reading enabled
burnDurationintBurn after reading message duration
groupAtTypeintGroup conversation announcement strong prompt type, special identifiers when someone @ownerUserID or @All in group announcement
attachedInfostringExtension field used by openIM
exstringExtension field used by users

Response Package Example

Allow Creation

Allow creating a single chat conversation.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": "",
"recvMsgOpt": 1,
"isPinned": true,
"isPrivateChat": false,
"burnDuration": 30,
"groupAtType": 0,
"attachedInfo": "Modified attached 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.
recvMsgOptintMessage receiving options, 0 for normal receipt; 1 for no message receipt; 2 for receiving messages without notification
isPinnedbooleanIs the conversation pinned
isPrivateChatbooleanIs burn after reading enabled
burnDurationintBurn after reading message duration
groupAtTypeintGroup conversation announcement strong prompt type, special identifiers when someone @ownerUserID or @All in group announcement
attachedInfostringExtension field used by openIM
exstringExtension field used by users