Skip to main content

Post Poll Conversation

Creates a new poll conversation in a chatroom. This function allows posting a poll with various settings such as poll type, multiple select options, anonymous voting, and expiration time. The function returns a response containing the created conversation details.

Steps to post a poll conversation

  1. Create a PostPollConversationRequest object using the builder pattern.
  2. Call the postPollConversation() function using the instance of LMChatClient, passing the request object and an optional response handler.
  3. Process the response LMResponse<PostPollConversationResponse> to handle the created poll conversation or any errors.
let request = PostPollConversationRequest.builder()
.chatroomId("ENTER_CHATROOM_ID")
.text("YOUR_TEXT")
.polls([Poll(question: "Feature 1"), Poll(question: "Feature 2")])
.pollType(1)
.isAnonymous(true)
.allowAddOption(false)
.expiryTime(86400) // 1 day in seconds
.build()

PollClient.shared.postPollConversation(request: request) { response in
if let result = response?.data {
// Handle success
print("Poll conversation created: \(result.conversation?.id ?? "N/A")")
} else if let error = response?.error {
// Handle error
print("Error posting poll conversation: \(error.localizedDescription)")
}
}

Models

PostPollConversationRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
chatroomIdStringID of the chatroom where the poll conversation is posted
textStringThe poll question or prompt
repliedConversationIdString?ID of the conversation this poll is replying to (if any)✔️
polls[Poll]Array of poll options for the conversation
pollTypeIntType of poll (e.g., single or multiple choice)
multipleSelectStateInt?State for multiple select options✔️
multipleSelectNoInt?Number of options users can select if multiple choice✔️
isAnonymousBoolWhether the poll is anonymous
allowAddOptionBoolWhether users can add their own poll options
expiryTimeIntExpiration time of the poll in seconds
temporaryIdString?Temporary ID for the poll conversation✔️
stateIntState of the conversation (default is active)

PostPollConversationResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
idString?ID of the created poll conversation✔️
conversationConversation?The full conversation object created with the poll✔️