Skip to main content

Creating a poll

A new poll can be created using the create method from the dyteClient.polls object. The dyteClient.polls.create() method accepts the following params.

ParamTypeDefault ValueRequiredDescription
questionstring-yesThe question that is to be voted for.
optionsstring[]-yesThe options of the poll.
anonymousboolean-yesIf true, the poll votes are anonymous.
hideVotesboolean-yesIf true, the votes on the poll are hidden.

The following snippet creates a poll where votes are anonymous.

question: "Are you an early bird or a night owl?",
options: ["Early bird", "Night owl"],
anonymous: true,
hideVotes: false,

Voting on a poll

The method can be used to register a vote on a poll. It accepts the following params.

ParamTypeDefault ValueRequiredDescription
pollMessageDytePollMessage-yesContains all the poll properties (question, options, etc.)
pollOptionDytePollOptionyesyesOption on which the user voted

The following snippet votes for the 1st option on the 1st poll created in the meeting.

final poll = dyteClient.polls.polls[0];
final selectedPollOption = poll.options[0];, selectedPollOption);