Skip to content

feat: add /send/pollVote endpoint to programmatically vote on polls #26

@in100tiva

Description

@in100tiva

Summary

Evolution Go currently exposes:

  • POST /send/poll — create a poll
  • GET /polls/:id/results — read the aggregated results

But there's no endpoint to programmatically cast a vote on an existing poll. This is a missing piece for CRM/dashboard integrations where users manage WhatsApp conversations from a web app — they can see polls in the chat timeline but can't interact with them (vote) from the same interface they use to reply to everything else.

Proposed endpoint

POST /send/pollVote

Request body (JSON):

{
  "number": "5511999999999",
  "pollMessageId": "3EB0000000000000000008",
  "selectedOptions": ["Option 1"]
}
  • number: recipient (the poll's chat JID)
  • pollMessageId: the messageId returned when the poll was created (POST /send/poll response)
  • selectedOptions: array of option names (the server computes the SHA-256 hash internally to build the pollUpdateMessage). Single-choice polls accept a 1-item array; multi-choice accept multiple.

Response: same shape as /send/poll ({success, message, messageId}).

Implementation sketch

whatsmeow already provides Client.SendMessage with pollUpdateMessage. Pseudocode (Go):

pollKey := &waCommon.MessageKey{
  RemoteJid: proto.String(chatJid),
  FromMe:    proto.Bool(true), // or resolve from original poll
  Id:        proto.String(pollMessageID),
}

hashes := make([][]byte, len(selectedOptions))
for i, opt := range selectedOptions {
  sum := sha256.Sum256([]byte(opt))
  hashes[i] = sum[:]
}

vote := &waE2E.Message{
  PollUpdateMessage: &waE2E.PollUpdateMessage{
    PollCreationMessageKey: pollKey,
    Vote: &waE2E.PollEncValue{
      EncPayload: ..., // encrypt via whatsmeow
      EncIV:      ...,
    },
    SenderTimestampMS: proto.Int64(time.Now().UnixMilli()),
  },
}

client.SendMessage(ctx, chatJid, vote)

The existing EncryptPollVote helper in whatsmeow handles the envelope encryption transparently.

Use case / motivation

We're building a multi-instance WhatsApp CRM on top of Evolution Go and the poll UI in the chat timeline is currently read-only because we can't send votes. Users have to switch to the phone to vote on their own polls, which breaks flow.

Adding this endpoint would close the poll feature parity with SendMessage/SendReaction/etc.

Happy to contribute a PR if the design looks good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions