/zaileys-official:zaileysfrom zaileys-official
Builds, debugs, and deploys WhatsApp bots using the zaileys TypeScript library. Covers WhatsApp Web (QR/pairing) and Meta Cloud API (webhooks, templates), including messages, media, buttons, groups, sessions, and error handling.
Ships in zaileys-official. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
zaileys (npm zaileys, docs https://zaileys.kejaa.id) wraps two ways of talking to WhatsApp behind one
Client: WhatsApp Web (provider: 'baileys', the default — a linked device of a normal account) and the
Cloud API (provider: 'cloud' — Meta's official API for business numbers). Handlers and sends look the
same on both; login, delivery, and the available features do not.
Your training data likely predates the current v4 API, and v3 code (a wa instance with a messages event,
prefix, session) or raw-Baileys habits (messages.upsert, useMultiFileAuthState, authDir) will not compile.
Treat the installed package as the source of truth:
node_modules/zaileys/package.jsonnode_modules/zaileys/dist/index.d.ts (search it before guessing).md to its URL, e.g. https://zaileys.kejaa.id/cloud/webhook.md| The user wants to… | Read first |
|---|---|
| Start a new bot or add zaileys to a project | workflows/new-bot.md, then references/storage-and-sessions.md |
| Add a feature to an existing bot | workflows/add-feature.md, then the topic reference below |
| Fix an error, a bot that doesn't reply, or a login loop | workflows/debug.md and references/errors.md |
| Review a bot before production | workflows/review.md |
| Upgrade zaileys or deploy to a server | workflows/upgrade-and-deploy.md, references/migration.md, references/production.md |
Topic references — open the one the task touches:
| Topic | File |
|---|---|
| WhatsApp Web vs Cloud API, what runs where, moving between them | references/providers.md |
| Sending: builder, media, buttons and lists, edits, reactions, JIDs | references/messaging.md |
| Receiving: events, message context, downloading media | references/receiving.md |
Commands, multi-step questions (ctx.ask), per-user state (ctx.session), middleware, plugins, broadcast, scheduling, auto-delete | references/bots.md |
| Groups, communities, channels | references/groups-and-channels.md |
| Cloud API setup, webhook, templates, 24-hour window, Meta limits | references/cloud-api.md |
| Auth and message stores, sessions, multiple accounts | references/storage-and-sessions.md |
| Every error code, message, disconnect reason, and Meta code | references/errors.md |
| Server sizing, media limits, ffmpeg, Docker, process managers, a session that stops receiving | references/production.md |
| Version history: v3 → v4 and changes within v4 | references/migration.md |
Templates for new projects are in assets/templates/web/ and assets/templates/cloud/. The read-only project
check is scripts/doctor.mjs (node scripts/doctor.mjs <project> [--json] [--online] from this skill's
directory). Read only the files the job needs.
msg.chatId is the message ID, not a chat. Sending to it fails with username "…" not found.
client.on('text', async (msg) => {
await msg.reply('pong') // quotes the message
await client.send(msg.roomId ?? msg.senderId).text('pong') // plain message to the same chat
})
roomId is typed string | null, which is why the fallback is required under strict.
Listen with client.on('message' | 'text' | 'image' | 'video' | 'audio' | 'document' | 'sticker' | …).
text ignores captions: a captioned photo fires message and image, with the caption in msg.text.
client.on() returns an unsubscribe function; there is no once.
zaileys doesn't await handler promises. An async handler that throws becomes an unhandled rejection, which
exits Node.js by default — wrap the work in try/catch:
client.on('image', async (msg) => {
if (msg.media?.type !== 'image') return
try {
const photo = await msg.media.buffer()
await client.send(msg.roomId ?? msg.senderId).image(photo, { caption: 'Got it' })
} catch (error) {
console.error('image handler failed:', error)
}
})
new Client() starts connecting on the next tick (autoConnect: true), so register handlers right after
constructing it. Reconnects with backoff are built in. Calling client.connect() from a disconnect handler
stacks a second retry loop on top, and every extra login attempt counts against the number — log instead:
client.on('disconnect', ({ reason, willReconnect }) => {
if (!willReconnect) console.error(`stopped: ${reason}`)
})
client.on('error', ({ error }) => console.error('zaileys:', error.message))
Without an error listener a failed automatic connect (bad token, invalid pairing number) prints nothing.
| Use | Not |
|---|---|
sessionId: 'shop' — 1–64 chars of A-Z a-z 0-9 _ -, otherwise the constructor throws | session, ids with . / : @ |
authType: 'qr' | 'pairing' with phoneNumber: '6281234567890' (string, country code, no +) | numeric phoneNumber |
commandPrefix: '!' | prefix |
auth: new FileAuthStore({ basePath }) or a database store | authDir, useMultiFileAuthState |
The default session lives in ./.zaileys/auth/<sessionId>, relative to the directory the process starts in.
Changing sessionId points at a new, empty folder — the bot asks for a new QR unless the old folder is
renamed to match.
Only a logged-out disconnect erases stored credentials.
connection-replaced (another process uses the same session) and forbidden stop the client but keep the
session; network reasons and bad-session reconnect. session.clearAuthOn changes which reasons erase.
Run one process per session: two processes on one session kick each other off.
authGuard stops after 5 QR codes or 3 pairing codes, and operationGuard spaces out group, community, and
channel operations. Both are on by default; { enabled: false } is how login loops get numbers restricted.
Send to many chats with client.broadcast(jids, (b) => b.text('…')), which paces sends (1/s by default),
instead of a for loop over client.send().
client.webhook() — a (req: Request) => Promise<Response>
handler you mount on a public HTTPS route. It requires cloud.appSecret and verifies the signature over the
raw body; unsigned or re-serialized bodies get 401. In Express, mount it with
express.raw({ type: '*/*' }) and never express.json() on that route.131047; use client.sendTemplate(to, name, language, components) with an approved template. The
send builder's .template() is a normal button message, not a Meta template.client.group, privacy, newsletter, community, profile, chat,
contact, business, presence, edit(), delete(), pin() throw UNSUPPORTED_ON_CLOUD. Commands,
middleware, plugins, broadcast(), scheduleAt(), forward(), and auto-delete need the WhatsApp Web
connection and don't run on the Cloud API — handle text events instead.Every zaileys error class (ZaileysBuilderError, ZaileysCloudError, ZaileysProviderError,
ZaileysCommandError, ZaileysDomainError, ZaileysAutomationError, ZaileysConnectionError,
ZaileysStoreError) has a code, and
wrapped failures keep the original in error.cause. Branch on instanceof and code, not on message text.
Set ZAILEYS_DEBUG=1 to see logs that are silent by default (failed handlers, failed commands).
zaileys installs a matching ffmpeg for the platform and uses the one on PATH only when no bundled binary
exists (override with FFMPEG_PATH). sharp is optional and speeds up images. Don't add
apt-get install ffmpeg to Dockerfiles by reflex. The exception: animated stickers need ffmpeg's libwebp
encoder, which some bundled builds lack (darwin-arm64 does) — the doctor script checks it, and the fix is an
ffmpeg with libwebp plus FFMPEG_PATH.
npx tsc --noEmit. A type error on a zaileys call
means the API is different from what you assumed — look it up in dist/index.d.ts, don't cast it away.[zaileys] Connected as ….
For the Cloud API, connect fires once Meta accepts the token; the webhook must answer Meta's GET
verification with the challenge.assets/templates/cloud/package.json (opens in a new tab)assets/templates/cloud/src/server.ts (opens in a new tab)assets/templates/cloud/tsconfig.json (opens in a new tab)assets/templates/web/package.json (opens in a new tab)assets/templates/web/src/bot.ts (opens in a new tab)assets/templates/web/tsconfig.json (opens in a new tab)references/bots.md (opens in a new tab)references/cloud-api.md (opens in a new tab)references/errors.md (opens in a new tab)references/groups-and-channels.md (opens in a new tab)references/messaging.md (opens in a new tab)references/migration.md (opens in a new tab)references/production.md (opens in a new tab)references/providers.md (opens in a new tab)references/receiving.md (opens in a new tab)references/storage-and-sessions.md (opens in a new tab)scripts/doctor.mjs (opens in a new tab)workflows/add-feature.md (opens in a new tab)workflows/debug.md (opens in a new tab)workflows/new-bot.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub zeative/zaileys --plugin zaileys-officialOther plugins' skills for the same job