Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jzszdznzzl/WABotJS/llms.txt

Use this file to discover all available pages before exploring further.

WABotJS is a high-level TypeScript library that makes it easy to build WhatsApp bots. It wraps the Baileys WebSocket library with a clean event-driven API for authentication, message handling, command routing, and media operations — all backed by SQLite for zero-dependency session persistence.

Quickstart

Connect your first bot and respond to messages in under 5 minutes.

Authentication

Log in with a QR code or phone number OTP pairing flow.

Command Routing

Build slash-style command handlers with automatic prefix parsing.

API Reference

Complete reference for every class, method, and utility.

Why WABotJS?

WABotJS handles the boilerplate so you can focus on your bot’s logic. Out of the box you get:

Session Persistence

Auth credentials and message history stored in SQLite — no Redis, no external service needed.

QR & OTP Login

Supports both QR-code scanning and phone-number OTP pairing for headless or interactive deployments.

Auto-Reconnect

Exponential back-off reconnection handles transient network drops without any extra code.

Typed Messages

The Message class normalises raw Baileys events into a consistent, fully-typed surface with helpers for reply, react, edit, download, and more.

Getting Started

1

Install the package

npm install wabotjs
Requires Node.js v24 or later and an ESM-compatible project ("type": "module" in package.json).
2

Create your bot

bot.ts
import { Bot } from 'wabotjs';
import qrcode from 'qrcode';

const bot = new Bot('my-bot', './data/my-bot');

bot.onQR(async (str) => {
  console.log(await qrcode.toString(str, { type: 'terminal', small: true }));
});

bot.onOpen(async (user) => {
  console.log('Connected as', user.name);
});

bot.onMessage(async (m) => {
  console.log('New message from', m.sender, ':', m.text);
});

await bot.login();
3

Add command handlers

bot.onCommand(async (m, prefix, name, args) => {
  if (name === 'ping') {
    await m.reply({ text: 'Pong!' });
  }
});
4

Run your bot

node --experimental-sqlite bot.ts
Scan the QR code that appears in your terminal and your bot is live.
WABotJS requires Node.js v24+ because it uses the native node:sqlite module introduced in that version. No additional SQLite bindings are needed.

Build docs developers (and LLMs) love