Skip to main content
Level: Beginner · Tags: WhatsApp, Telegram, Triggers Features shown: trigger forms · reply helpers · ctx.react() · ctx.senderInfo, ctx.sender, ctx.isGroup · catch-all

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 --name Ana:

How it works

  • Exact by default. bot.when('hi') matches the whole message after normalizing case, accents and spaces: “Hi” matches, “hi there” does not.
  • match: 'contains' (also 'startsWith' and 'endsWith') matches part of the message; a regex matches anywhere in it.
  • Specificity decides when several triggers match: exact text beats regex, regex beats contains (see Precedence).
  • ctx.quote(text) replies quoting the incoming message; ctx.react(emoji) reacts to it (channels without reactions skip it).
  • ctx.senderInfo.displayName is the sender’s profile name when the transport reports one; ctx.sender is their stable id, the same in a DM and in a group.
  • Baileys has no native buttons: for a quick choice use a poll or a numbered menu.

Run it on WhatsApp or Telegram

node bot.js prints a QR: scan it in WhatsApp → Linked devices. For Telegram, install @botmesh/telegram and swap the provider as shown in Or connect Telegram; the factory does not change.

Next steps