Requirements
- Node.js 22.12 or newer (download). Check with
node -v. - npm (bundled with Node) or pnpm. The commands below use npm; with
pnpm, write
pnpm add,pnpm createandpnpm exec. On pnpm 11, installing@botmesh/baileysfirst stops withERR_PNPM_IGNORED_BUILDS; see Troubleshooting. - To connect for real: a phone with WhatsApp (its number becomes the bot) or a Telegram bot token from @BotFather. The terminal simulator needs neither.
Betabotmesh is in beta: a plain install gets the beta, and
@beta always resolves to the newest one (latest is moved by hand after each publish). This site documents the beta, then @botmesh/core 2.0.0 stable.Option A: scaffold a project (recommended)
create-botmesh generates a project that runs both in the simulator and on
the real channel:
hola, then menu, then /help. When you are happy with it, connect
the real channel:
.env lacks a variable the project needs, npm start stops with one line
naming it (Missing TELEGRAM_TOKEN: copy .env.example to .env ...) before
connecting anything.
The templates are written in Spanish and set lang: 'es'. The full list of
templates, the CLI flags and the generated files are in
Project templates.
Option B: set it up by hand
1. Install
@botmesh/telegram instead of @botmesh/baileys, and
use the Telegram version of bot.js from
Or connect Telegram: the file below imports
@botmesh/baileys, so it does not load without it. botmesh ships only ES modules, so the project needs "type": "module" (or
.mjs files) and you load the packages with import.
2. Write the bot
Createbot.js. The bot is a factory (defineBot): it receives a
provider and returns the configured Bot. The same file then runs in the
simulator and on the real channel:
3. Try it in the terminal
:help lists its commands and
:quit exits. More in Terminal simulator.
4. Connect a real channel
Link WhatsApp
- Open WhatsApp → Settings → Linked devices.
- Tap Link a device and scan the QR.
✅ Connected prints, send hi to that number from another phone.
The login is saved in ./sessions/my-bot/, so the next start reconnects
without a QR. Keep that folder private and out of git: whoever has it controls
the account.
Or connect Telegram
Create a bot with @BotFather (/newbot) and copy
its token. In bot.js, change two places: the provider import at the top and
the start block at the bottom. The factory in between stays the same.
.env next to bot.js with your editor, containing one
line:
echo ... > .env in Windows PowerShell: it writes the file as UTF-16
or with a BOM, Node does not read the variable, and the provider stops with
`token` is required. Then start the bot:
hi. The provider uses long polling by
default, so no public URL is needed.
Other channels
Only the provider changes: handlers, flows, hooks and plugins are the same on every transport.
The official WhatsApp Cloud API, for example:
provider.ingest(rawBody, headers). See Webhook server to mount it
and Channels for what each transport supports.
Troubleshooting
Project templates
The use-case templates (
games to ai-full) run on Baileys. The transport
templates (baileys, meta, telegram, ai) install the built-in slash
commands, so /reset or /cancel escapes their sample menu flow.
Every project contains
package.json (with npm start and npm run dev),
src/bot.js, .env.example, .gitignore, a README.md and an
AGENTS.md that tells AI coding agents which API to use and which
commands to run.
Next steps
- Your first bot: commands, media, a validated flow and a catch-all
- Core concepts: how a message is routed,
ctx, triggers and ids - Configuration reference: every
new Bot({...})option - Channels: every transport and what it supports
- Testing: test your flows with
createTestBot, no network - Examples: copy-ready recipes
- Going to production and Troubleshooting