Skip to main content

Add Poll Option

The addPollOption() method allows you to add an option to a poll in a specific conversation. The request requires the poll text and the conversationId. The response provides the added poll option.

Steps to Add a Poll Option

  1. Create an AddPollOptionRequest object with the required parameters: poll (poll option text) and conversationId.
  2. Call the addPollOption() function using the instance of the LMChatClient class.
  3. Use the response LMResponse<AddPollOptionResponse> to retrieve the newly added poll option.
AddPollOptionRequest request = (AddPollOptionRequestBuilder()
..poll('ENTER_POLL_TEXT') // Provide the poll option text
..conversationId("ENTER_CONVERSATION_ID")) // Provide the conversation ID
.build();

final LMResponse<AddPollOptionResponse> response =
await lmChatClient.addPollOption(request);

if (response.success) {
// Handle the added poll option
PollOption addedPollOption = response.data?.poll ?? PollOption();
handleAddedPollOption(addedPollOption);
} else {
// Handle error
handleError(response);
}
tip

Ensure that both poll (poll option text) and conversationId are provided to add a new option to the poll.

Models

AddPollOptionRequest

List of parameters for the AddPollOptionRequest class:

VariableTypeDescriptionOptional
pollStringThe text of the poll option
conversationIdintThe ID of the conversation

AddPollOptionResponse

List of parameters for the AddPollOptionResponse class:

VariableTypeDescriptionOptional
pollPollOptionThe added poll option✔️