Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
Message
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Update a poll

You can update a specific poll by creating and passing the PollUpdateParams parameters in the channel.updatePoll() method.

const params: PollUpdateParams = {
  title: 'My poll',
  optionTexts: [
    'First option',
    'Second option',
  ],
  data: { text: 'My poll data' },
  isAnonymous: true,
  allowUserSuggestion: true,
  allowMultipleVotes: true,
  closeAt: Math.floor(Date.now() / 1000 + oneDayInSeconds),
};
const updatedPoll: Poll = await channel.updatePoll(pollId, params);

PollUpdateParams

Parameter nameTypeDescription

title?

string

Specifies the title of a poll.

data?

PollData

Specifies an additional data to accompany the poll. A use case might be to provide explanations for incorrect quiz answers.

isAnonymous?

boolean

Determines whether to make votes anonymous. (Default: false)

allowUserSuggestion?

boolean

Determines whether to allow users to make suggestions. (Default: false)

allowMultipleVotes?

boolean

Determines whether to allow users to vote on more than one poll options. (Default: false)

closeAt?

number

Specifies the time when a poll has closed or will close in Unix seconds.