A TypeScript framework for messaging bots. Write handlers and conversation flows once and run them on WhatsApp (the unofficial Baileys 7 protocol or the official Meta Cloud API) and Telegram, with experimental providers for Messenger, Instagram, Discord, TikTok, email and more WhatsApp gateways (Evolution API, WPPConnect, Twilio, Gupshup). Try your bot in the terminal before connecting a phone, test it without a network, and add AI, persistence or multiple replicas when you need them.
Documentation: https://andresayac.github.io/botmesh/ (English Β· EspaΓ±ol Β· API reference)
import { Bot, flow } from '@botmesh/core'
import { BaileysProvider } from '@botmesh/baileys'
const bot = new Bot({ provider: new BaileysProvider({ session: 'my-bot' }) })
bot.when('hi', (ctx) => ctx.reply('π Hello!'))
bot.use(
flow('signup')
.ask('What is your name?', 'name')
.say((_ctx, c) => `Nice to meet you, ${c.state.name}!`),
)
await bot.start() // scan the QR with WhatsApp β Linked devicesSwap BaileysProvider for TelegramProvider (@botmesh/telegram) or CloudAPIProvider (@botmesh/meta) and the rest stays the same.
npm create botmesh my-bot # templates: baileys, telegram, meta, ai, store, supportβ¦
cd my-bot && npm install
npm run dev # chat with the bot in the terminal: no phone, no credentials
npm start # connect the real channelOr add it to an existing project (Node >= 22, ESM-only):
npm install @botmesh/core @botmesh/baileys # WhatsApp (Baileys)
npm install @botmesh/core @botmesh/telegram # Telegram
npm install @botmesh/core @botmesh/meta # WhatsApp Cloud API
npm install @botmesh/ai @anthropic-ai/sdk # + AI (optional; the SDK of the provider you use)Prerelease. botmesh is not stable yet, and these docs describe the upcoming release. During the beta, add the tag to these commands (
npm create botmesh@beta,npm install @botmesh/core@beta β¦): without it npm installslatest, which can still point to an older alpha. Until the beta is published, npm only has older alphas that differ from the docs in places (built-in texts default to Spanish,pairingCodeinstead ofpairingPhoneNumber, and a scaffolded project needs a.envbeforenpm start). Once@botmesh/core2.0.0 ships, the commands work as written.
The getting started guide walks through the simulator, linking WhatsApp and connecting Telegram step by step.
AI on WhatsApp: since 2026-01-15 the WhatsApp Business Platform terms forbid general-purpose AI assistants (open ChatGPT-style chatbots). AI in the service of the business (support, sales, bookings) is allowed. Details in the AI plugin guide.
This is a pnpm monorepo with 45 packages: 10 Public, 27 Experimental and 8 Product and internal ones. They are not all equally mature, and the Status column says so plainly:
- Public: published on npm and covered by semver from the stable release on (prerelease builds until then).
- Experimental: real, tested implementation, but the package is
private. Not published yet and its API may change. - Product / internal: real, persistent implementation (
private) over any coreDurableKv. Per-tenant isolation and compare-and-set in the backend; the API may still change.
| Package | Status | Description |
|---|---|---|
| Core | ||
@botmesh/core |
Public | Transport-agnostic engine: Bot, IProvider v2, dispatcher, flows/conversations, hooks, plugins, store, testing kit. |
| Transports (channels) | ||
@botmesh/baileys |
Public | WhatsApp through Baileys 7 (unofficial, QR or pairing code). |
@botmesh/meta |
Public | Official WhatsApp Cloud API (webhook, no ban risk, native buttons/lists/templates). |
@botmesh/telegram |
Public | Telegram Bot API (long-poll/webhook, inline keyboards, native polls). |
@botmesh/messenger |
Experimental | Facebook Messenger (Meta Graph, quick replies/templates). |
@botmesh/instagram |
Experimental | Instagram DM (Meta Graph, quick replies). |
@botmesh/discord |
Experimental | Discord (gateway websocket + REST, slash/components). |
@botmesh/evolution |
Experimental | WhatsApp through Evolution API (self-hosted REST gateway, signed webhook). |
@botmesh/wppconnect |
Experimental | WhatsApp through WPPConnect Server (REST + token webhook). |
@botmesh/twilio |
Experimental | WhatsApp and SMS through Twilio Programmable Messaging (X-Twilio-Signature webhooks). |
@botmesh/gupshup |
Experimental | WhatsApp through Gupshup (API v1 + v2 callbacks). |
@botmesh/gohighlevel |
Experimental | GoHighLevel / LeadConnector (Conversations API + signed InboundMessage webhooks). |
@botmesh/email |
Experimental | Email: inbound IMAP IDLE + outbound SMTP, threading, loop and bounce protection. |
@botmesh/tiktok |
Experimental | TikTok API for Business: DMs (Business Messaging) and replies to comments on your own videos. |
| Stores (persistence) | ||
@botmesh/sqlite-store |
Public | SQLite (better-sqlite3, WAL). |
@botmesh/redis-store |
Public | Distributed Redis (+ multi-replica lock). |
@botmesh/mongo-store |
Experimental | MongoDB. |
@botmesh/postgres-store |
Experimental | PostgreSQL (pg). |
@botmesh/mysql-store |
Experimental | MySQL/MariaDB (mysql2). |
| Plugins | ||
@botmesh/ai |
Public | AI: Anthropic/OpenAI/Ollama/Gemini + 9 OpenAI-compatible presets (DeepSeek/Qwen/GLM/Kimi/Groq/β¦), auto-reply, tool calling with confirmation, per-user long-term memory and RAG. See the WhatsApp AI policy. |
@botmesh/nlu |
Experimental | Local intents/NLU (define/match + whenIntent), no external services. |
@botmesh/manager |
Experimental | Multi-bot orchestrator (registry, lifecycle) + dependency-free HTTP API (control plane /v1 with API keys). |
@botmesh/otel |
Experimental | OpenTelemetry: bot traces (inbound, dispatch, conversations, sends, AI) and bot.metrics() as OTel metrics. @opentelemetry/api as an optional peer. |
@botmesh/events |
Experimental | Versioned envelopes, idempotent journal, retries and DLQ for asynchronous processes. |
@botmesh/rag |
Experimental | RAG for @botmesh/ai: loaders, chunking, pluggable embeddings (OpenAI-compatible, Ollama, local hashing) and an in-memory vector index with optional JSON persistence. |
@botmesh/voice |
Experimental | Voice: voice-note transcription (OpenAI-compatible, Deepgram) and spoken replies (OpenAI, ElevenLabs). |
@botmesh/chatwoot |
Experimental | Chatwoot bridge: two-way sync and human handoff driven by Chatwoot agents. |
@botmesh/tickets |
Experimental | Support tickets and queues (ctx.tools.tickets): queue position, business hours and store persistence. |
@botmesh/moderation |
Experimental | Group moderation: anti-spam, word/regex and invite-link filters, warn/mute/kick/delete actions. |
@botmesh/dialogflow |
Experimental | Dialogflow ES/CX: detectIntent over REST (service-account JWT, no Google SDK) and intent routing to flows. |
| Shared infrastructure (dependencies of the public packages) | ||
@botmesh/http |
Public | Safe HTTP client: anti-SSRF, redirect validation, timeouts and download limits. |
@botmesh/graph-core |
Public | Shared Meta Graph helpers (webhook verification, error mapping, ingest guard) used by meta/messenger/instagram. |
@botmesh/wa-gateway-kit |
Internal | Code shared by the WhatsApp REST gateways (evolution, wppconnect): REST client over secureFetch, outbound media resolution and LID/PN identity reconciliation. Private; not installed directly. |
@botmesh/server |
Experimental | Webhook ingress for the providers: raw body, size limits, timeouts, concurrency and health endpoints for node:http, Express, Fastify and Hono (no dependencies). |
| Product / operations (private, persistent) | ||
@botmesh/inbox |
Product | Persistent omni-channel inbox: CAS assignment, handoff, notes, unread, SLA and ledger projection (attachInbox). |
@botmesh/crm |
Product | Contacts, tags, attributes, consent (lossless CAS) and per-tenant segments. |
@botmesh/hub |
Product | Per-tenant plugin registry: validated manifests and permission-gated enabling. It does not run or sandbox code. |
@botmesh/campaigns |
Product | Consent-aware campaigns: durable per-recipient reservations (TTL), atomic settlement and sendCampaign() over bot.broadcast(). |
@botmesh/deployments |
Product | Immutable versions, active version, gate reservations, rollback and audited gate runs (including the golden-transcript gate). |
@botmesh/tenant-kv |
Internal | Per-tenant JSON documents with compare-and-set over any DurableKv: the base of the product packages. |
@botmesh/flow-schema |
Internal | Versioned JSON schema for code-free flows, safe expressions, compilation to CompiledFlow, reverse export, migrations and deployment helpers. |
| Tooling | ||
create-botmesh |
Public | CLI scaffolder (npm create botmesh), 10 templates: baileys, meta, telegram, ai and the use-case ones games, support, store, restaurant, clinic, ai-full. Every project ships an AGENTS.md for coding agents. |
eslint-plugin-botmesh |
Experimental | ESLint rules for bots: v1 API leftovers, blocking runtime.enter, async install, empty triggers, ask without timeout and per-user global state. |
@botmesh/sandbox |
Experimental | Local simulators of WhatsApp Cloud API, Messenger, Instagram, Twilio, Gupshup, HighLevel, TikTok, Discord and Telegram (signed webhooks, realistic errors, request-shape checks) with a web chat UI: pnpm sandbox. Docker suites for Evolution API, WPPConnect, Chatwoot and Mailpit. |
@botmesh/mcp |
Experimental | Stdio MCP server (no dependencies) for agents: validates, compiles, renders, lints, migrates and diffs JSON flow documents without starting a bot; with --docs it searches these guides. |
pnpm install # install the whole workspace
pnpm build # pnpm -r build β compiles every package
pnpm test # pnpm -r test β full suite
pnpm run docs # TypeDoc + VitePress β documentation sitePer package: pnpm --filter @botmesh/ai test, pnpm --filter @botmesh/core build, and so on.
| Example | What it shows |
|---|---|
examples/bakery-ai |
AI ordering assistant for a bakery (in English) on WhatsApp, through Baileys (QR) or Twilio (webhook with @botmesh/server). Tools with confirmation, totals computed in code, dedupe, an access list, typed configuration and tests with no network. |
They build and test with the rest of the workspace (pnpm build, pnpm test). Each example ships its own README with the commands to run it.
- Documentation site: https://andresayac.github.io/botmesh/ (English guide, Spanish guide under
/es/and the API reference). Sources indocs/(English indocs/guide/, Spanish indocs/es/guide/); preview locally withpnpm docs:dev. - Upgrading from an alpha: Migrating to stable. From v1 (
BaileysClass):docs/MIGRATION-v1-to-v2.md. - Product and engineering roadmap:
ROADMAP.md. - Detailed catalogue of proposals:
FEATURES.md. - Vulnerability reporting policy:
SECURITY.md. - Design and decisions:
docs/superpowers/specs/anddocs/superpowers/plans/.
See CONTRIBUTING.md. Relevant changes go in CHANGELOG.md.
MIT Β© Andres Aya