Post Conversation
Creates a new conversation based on the specified request. This function handles posting a conversation with the provided details and returns a response indicating success or failure.
Steps to post a conversation
- Create a PostConversationRequest object using the builder pattern.
- Call the
postConversation()
function using the instance ofLMChatClient
, passing therequest
object and an optional response handler. - Process the response LMResponse<PostConversationResponse> to handle the created conversation or error cases.
let request = PostConversationRequest.Builder()
.chatroomId("ENTER_CHATROOM_ID")
.text("YOUR_TEXT")
.isFromNotification(false)
.shareLink("https://example.com")
.attachmentCount(3)
.temporaryId("ENTER_TEMPORARY_ID")
.repliedConversationId("ENTER_CONVERSATION_ID")
.repliedChatroomId("ENTER_CHATROOM_ID")
.build()
LMChatClient.shared.postConversation(request: request) { response in
if let result = response?.data {
// Handle success
print("Conversation posted successfully: \(result.conversation)")
} else if let error = response?.error {
// Handle error
print("Error posting conversation: \(error.localizedDescription)")
}
}
Models
PostConversationRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
chatroomId | String | ID of the chatroom where the conversation is posted | |
text | String | Text content of the conversation | |
isFromNotification | Bool | Indicates if the conversation was initiated by a notification | |
shareLink | String? | Optional URL or link to share in the conversation | ✔️ |
ogTags | LinkOGTags? | Optional Open Graph tags associated with the shared link | ✔️ |
repliedConversationId | String? | ID of the conversation being replied to, if any | ✔️ |
attachmentCount | Int? | Number of attachments included in the conversation | ✔️ |
temporaryId | String? | Temporary ID used to identify the conversation locally | ✔️ |
repliedChatroomId | String? | ID of the chatroom for the replied conversation, if applicable | ✔️ |
PostConversationResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
conversation | Conversation | The created conversation object | ✔️ |
id | String | Unique identifier for the conversation | ✔️ |
widgets | [String: Widget] | Widgets associated with the conversation, if any | ✔️ |