Skip to main content

Submit Poll

The submitPoll() method is used to submit the poll responses for a specific conversation. This requires the conversationId and the selected polls that are submitted by the user.

Steps to Submit a Poll

  1. Create a SubmitPollRequest object using the builder pattern, providing the necessary parameters such as the conversationId and polls (list of selected poll options).
  2. Call the submitPoll() function using the LMChatClient instance.
  3. The method returns LMResponse<void>, which you can use to check whether the poll was successfully submitted or if an error occurred.
SubmitPollRequest request = (SubmitPollRequestBuilder()
..conversationId("ENTER_CONVERSATION_ID") // Provide the conversation ID
..polls([PollOption('Option 1'), PollOption('Option 2')])) // Provide selected poll options
.build();

final LMResponse<void> response = await lmChatClient.submitPoll(request);

if (response.success) {
// Handle successful poll submission
handleSuccess();
} else {
// Handle error
handleError(response);
}
tip

Ensure that conversationId and polls are correctly set before sending the request to submit the poll.

Models

SubmitPollRequest

List of parameters for the SubmitPollRequest class:

VariableTypeDescriptionOptional
conversationIdintThe ID of the conversation where the poll was posted
pollsList<PollOption>List of poll options selected by the user