Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Meeting Polls: Create, Vote, Results, and Events

How meeting.polls works in RealtimeKit: create polls, cast votes, read results, listen for updates, use UI components, and fix error 5001.

This page summarises Cloudflare RealtimeKit documentation on polls inside a live meeting: the meeting.polls object on RealtimeKitClient, the Poll data model, voting and results, real-time listeners, prebuilt UI Kit pieces, and poll-related error codes.

This guide explains how to create, vote on, and interact with polls in a meeting using Cloudflare RealtimeKit.

— Cloudflare, Polls

meeting.polls: what the polls object does in a meeting

Section titled “meeting.polls: what the polls object does in a meeting”

The polls object holds polls started in the meeting and exposes methods to create them and register votes.

The polls object stores the polls that were initiated in the meeting. It exposes methods to create and vote on polls.

— Cloudflare, RealtimeKitClient — meeting.polls

You reach it from an active meeting client as meeting.polls. The Polls guide and RTKPolls API reference document the same surface:

Member Role
meeting.polls.items Array of every Poll in the meeting
meeting.polls.create(question, options, anonymous, hideVotes) Create a new poll
meeting.polls.vote(pollId, index) Cast a vote on an option by index

The meetings polls object can be accessed using meeting.polls. It provides methods to create polls, vote, and more.

— Cloudflare, Polls — Introduction

meeting.polls.items returns an array where each element is a Poll object (Poll Type).

Poll and PollOption: poll shape, anonymous votes, and hidden counts

Section titled “Poll and PollOption: poll shape, anonymous votes, and hidden counts”

A poll is the question, settings, options, and who has voted. Each option carries text, a vote list, and a count.

On JavaScript/TypeScript, the documented interfaces are:

Field (Poll) Meaning
id Poll identifier (used when voting)
question Text shown to participants
options List of PollOption
anonymous Whether votes are anonymous
hideVotes Whether vote counts are hidden
createdBy / createdByUserId Creator metadata
voted Participant IDs who voted on this poll

Each PollOption has text, votes (voter id and name when not anonymous), and count.

Native SDKs expose the same concepts as Poll, PollOption, and PollVote classes (Poll Type). When anonymous is true, the UI and API still track participation for meeting logic, but voter identity is not exposed in the way open polls are.

When hideVotes is true, clients should not show per-option tallies until your product rules allow it—the flag is set at creation time via create (RTKPolls.create).

Create a poll: question, options, anonymous, and hideVotes

Section titled “Create a poll: question, options, anonymous, and hideVotes”

Creation goes through meeting.polls.create (or platform-named equivalents such as createPoll on some Apple APIs in the Polls — Creating a Poll examples).

Parameter Type Default (JS API ref) Purpose
question string — (required) Wording participants vote on
options string[] / list — (required) Answer choices
anonymous boolean false Anonymous voting when true
hideVotes boolean false Hide vote counts when true

Creates a poll in the meeting.

— Cloudflare, meeting.polls.create

Example with anonymous voting (from the Polls guide):

await meeting.polls.create(
"Are you an early bird or a night owl?",
["Early bird", "Night owl"],
true,
);

On Kotlin, create returns PollsError? so you can handle validation failures without throwing (Meeting Object Explained — polls). Always pass a non-empty question and at least one option string—empty questions trigger error 5001.

Voting is done with meeting.polls.vote, passing the poll’s id and the zero-based index of the chosen option.

Casts a vote on an existing poll.

— Cloudflare, meeting.polls.vote

const poll = meeting.polls.items[0];
await meeting.polls.vote(poll.id, 0);

On Kotlin and Swift, the Polls — Voting on a Poll snippets pass a Poll and PollOption instance instead of a numeric index—use whichever signature your SDK version exports, but always take poll.id from meeting.polls.items rather than caching stale objects after updates.

Retrieve pollId from meeting.polls.items after creation or from an onNewPoll callback (Meeting Object Explained).

View poll results: voted, options, and count

Section titled “View poll results: voted, options, and count”

You do not need a separate “results API”: read the current Poll from meeting.polls.items.

  • Who voted (poll level): poll.voted — array of participant IDs (same id space as meeting.participant.id) (Polls — View Poll Results).
  • Per-option breakdown: poll.options — each PollOption includes votes and count.
const poll = meeting.polls.items[0];
const votes = poll.voted;
const options = poll.options;

Refresh the UI when polls change (see listeners below); after a vote, counts and voted update on the next onPollUpdate / onPollUpdates event.

Poll events: onNewPoll, onPollUpdate, and onPollUpdates

Section titled “Poll events: onNewPoll, onPollUpdate, and onPollUpdates”

For custom UI, subscribe to poll events on the meeting client. Kotlin’s pattern from Meeting Object Explained:

  • onNewPoll — a poll was created.
  • onPollUpdate — one poll changed (votes or metadata).
  • onPollUpdates — batch/list refresh.

Register with meeting.addPollsEventListener (or the equivalent extension on your platform). Keeping meeting.polls.items in sync with these callbacks avoids showing stale vote counts.

UI Kit: ready-made poll components vs meeting.polls

Section titled “UI Kit: ready-made poll components vs meeting.polls”

RealtimeKit’s UI Kit wraps the same meeting state so you do not have to rebuild forms and lists.

Component Use when
rtk-poll / RtkPoll Show one poll and let the user vote
rtk-poll-form / RtkPollForm Host UI to create a poll (question, options, anonymous / hide toggles on RN)
rtk-polls / RtkPolls Full panel: list, vote, and create (RN: “hosts” form included)
rtk-polls-toggle Button to open polls sidebar; needs meeting for unread badge
RtkPollsBottomSheet / RtkCreatePollBottomSheet Android sheets for list and create

A button which toggles visibility of polls. You need to pass the meeting object to it to see the unread polls count badge. When clicked it emits a rtkStateUpdate event with the data: { activeSidebar: boolean; sidebar: 'polls' }

— Cloudflare, rtk-polls-toggle

Pass meeting (and poll for single-poll views) into components as shown in React RtkPoll and React RtkPolls. React Native’s RtkPoll documents optional onRtkVotePoll when you want a custom handler alongside the built-in vote flow.

Code Message Typical cause Fix
5001 Poll question cannot be blank Empty question passed to create Ensure the question string has text before creating the poll

Error message: Poll question cannot be blank
Possible reason: An empty poll question was provided.
Possible solution: Ensure the poll question contains text before creating the poll.

— Cloudflare, Error Codes — 5001

Common mistakes when implementing meeting polls

Section titled “Common mistakes when implementing meeting polls”
  • Calling vote with a stale poll object after someone else voted—prefer ids from fresh items or event payloads.
  • Using the wrong option identifier on JS (index number) vs Kotlin/Swift (PollOption object)—match your SDK’s vote overload.
  • Ignoring hideVotes and anonymous when building results UI—participants expect counts and names to match those flags.
  • Forgetting to attach poll listeners so the list never updates after create or vote.
  • Typos in sample code—some snippets in the wild use meeting.poll instead of meeting.polls; the documented module is RTKPolls on meeting.polls.
  1. Join a test meeting with RealtimeKit, open the browser or native debugger, and confirm meeting.polls is defined per the Polls introduction.

  2. Create a poll with a non-empty question through your UI or meeting.polls.create, then verify it appears in meeting.polls.items (RTKPolls.items).

  3. Cast a vote with meeting.polls.vote(poll.id, index) and confirm poll.voted and the chosen option’s count update (View Poll Results).

  4. Trigger a second client in the same meeting and confirm onNewPoll / onPollUpdate fire when polls are created or voted on (Meeting Object Explained — polls).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match your SDK behaviour or the official docs, send a note to yimasynthetic@gmail.com with the page URL and the exact wording you think is wrong, and we will clarify or correct it.