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
- Create a
SubmitPollRequestobject using the builder pattern, providing the necessary parameters such as theconversationIdandpolls(list of selected poll options). - Call the
submitPoll()function using theLMChatClientinstance. - 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:
| Variable | Type | Description | Optional |
|---|---|---|---|
conversationId | int | The ID of the conversation where the poll was posted | |
polls | List<PollOption> | List of poll options selected by the user |