Votes: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.

Show and change a comment vote

A comments interface can let a visitor or member express an opinion and change it later. Keep the same authenticated identity throughout this flow.

Prerequisite: Use a comment in a context that allows the caller to vote. The app ID and context ID must match that comment's integration.

To cast, change, and remove a vote:

  1. Take the comment ID from the displayed comment and prepare its contextData.
  2. Call Upvote with the comment ID as resourceId, wix.comments.v2.comment as resourceFqdn, and that contextData.
  3. Save the returned vote.voteId and display the selection from vote.type.
  4. Call Downvote with the same resource and context to change the vote. Refresh the displayed selection from the response.
  5. Call Remove Vote with the returned vote.voteId and the same context to clear the selection.

Restore vote controls after a page reload

When comments load, retrieve the current visitor's or member's votes to restore the voting controls. An application query can return other identities' votes and isn't a substitute for this personal query.

To restore the selections:

  1. Collect the displayed comment IDs that share the same app and context.

  2. Call Query Votes with the visitor's or member's authentication, that contextData, and a query.filter such as:

    Copy
  3. Retrieve the remaining pages using paging.cursors.next as query.cursorPaging.cursor, keeping the filter and context unchanged.

  4. Index the returned votes by resourceId and render each selection from type. After all pages are loaded, comments without a matching vote have no selection.

  5. Keep each voteId for later removal. Clear and reload personal vote state when the identity changes.

Last updated: 10 September 2026

Did this help?