Send DM Request
Sends a direct message request to another user. This function allows users to initiate or continue a direct message conversation by sending a message, updating the chat request state, or attaching additional metadata to the message.
Steps to send a DM request
- Create a SendDMRequest object using
SendDMRequest.builder()
class by passing all the required parameters. - Call
sendDMRequest()
function using the instance ofLMChatClient
. - Process the response LMResponse<SendDMResponse> as per your requirement.
let request = SendDMRequest.builder()
.chatRequestState(1)
.text("YOUR_TEXT")
.chatroomId("ENTER_CHATROOM_ID")
.metadata(["key": "value"]) // Optional: attach custom metadata
.build()
LMChatClient.shared.sendDMRequest(request: request) { response in
if let data = response.data {
// Process the send DM response
processSendDMResponse(data)
// Access metadata if present
if let metadata = data.conversation?.metadata {
print("Metadata: \(metadata)")
}
} else if let error = response.error {
// Handle the error
handleError(error)
}
}
Models
SendDMRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
chatRequestState | Int? | The state of the chat request | ✔️ |
text | String? | The message text to be sent | ✔️ |
chatroomId | String? | ID of the chatroom where the message is to be sent | ✔️ |
metadata | [String: Any]? | Custom metadata to attach to the message | ✔️ |
temporaryId | String? | Optional temporary identifier for the message | ✔️ |
SendDMResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
conversation | Conversation? | Information about the updated conversation, including any attached metadata | ✔️ |