Skip to main content

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

  1. Create a PostConversationRequest object using the builder pattern.
  2. Call the postConversation() function using the instance of LMChatClient, passing the request object and an optional response handler.
  3. 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

VARIABLETYPEDESCRIPTIONOPTIONAL
chatroomIdStringID of the chatroom where the conversation is posted
textStringText content of the conversation
isFromNotificationBoolIndicates if the conversation was initiated by a notification
shareLinkString?Optional URL or link to share in the conversation✔️
ogTagsLinkOGTags?Optional Open Graph tags associated with the shared link✔️
repliedConversationIdString?ID of the conversation being replied to, if any✔️
attachmentCountInt?Number of attachments included in the conversation✔️
temporaryIdString?Temporary ID used to identify the conversation locally✔️
repliedChatroomIdString?ID of the chatroom for the replied conversation, if applicable✔️

PostConversationResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
conversationConversationThe created conversation object✔️
idStringUnique identifier for the conversation✔️
widgets[String: Widget]Widgets associated with the conversation, if any✔️