Skip to main content
Level: Beginner · Tags: WhatsApp, Telegram, Polls, Reactions Features shown: ctx.poll() · poll votes (bot.on('poll')) · bot.send() outside a handler · ctx.react() · terminal simulator :click

Prerequisites

Node.js 22.12 or newer and a folder with "type": "module" (see Getting started). Then install:

The complete bot

Sample transcript

Captured with npx botmesh dev bot.js; :click 2 votes for the second option of the last poll:

How it works

  • ctx.poll(question, options, multiSelect?) sends a native poll. Polls are native on WhatsApp via Baileys and on Telegram; the WhatsApp Cloud API has none (ctx.poll() rejects with UnsupportedContentError there, use buttons, see the Menu bot).
  • Votes are events, not messages. bot.on('poll') receives { ref, senderId, options }, where options holds every option with its votes and voters. Changing or withdrawing a vote fires it again.
  • bot.send(chatId, text) sends outside a handler; vote.ref.chatId is the chat where the poll was voted.
  • ctx.react(emoji) reacts to the incoming message. Channels without reactions resolve { skipped: true } instead of failing.
  • On WhatsApp the votes are end-to-end encrypted: the provider decrypts them, but only for polls this process sent or saw (see Poll votes).

Run it on WhatsApp or Telegram

node bot.js prints a QR: scan it in WhatsApp → Linked devices. On Telegram, install @botmesh/telegram and swap the provider as shown in Or connect Telegram; its polls are sent non-anonymous so the votes reach the bot.

Next steps