Skip to main content

Add Poll Option

Adds a new option to an existing poll in a conversation. This function allows users to contribute additional options to a poll that supports the addition of new choices.

Steps to add a poll option

  1. Create an AddPollOptionRequest object using the builder pattern.
  2. Call the addPollOption() function using the instance of LMChatClient, passing the request object and an optional response handler.
  3. Process the response LMResponse<AddPollOptionResponse> to handle the added poll option or any errors.
let request = AddPollOptionRequest.builder()
.conversationId("ENTER_CONVERSATION_ID")
.poll(Poll.Builder().option("New Option").build())
.build()

PollClient.shared.addPollOption(request: request) { response in
if let result = response?.data {
// Handle success
print("Poll option added: \(result.poll)")
} else if let error = response?.error {
// Handle error
print("Error adding poll option: \(error.localizedDescription)")
}
}

Models

AddPollOptionRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
conversationIdStringID of the conversation the poll belongs to
pollPollThe poll option being added

AddPollOptionResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
pollPollThe newly added poll option