nduka
v1.0.5
Published
WhatsApp AI Gateway
Readme
WhatsApp AI Gateway
Production-ready WhatsApp AI Gateway built on Baileys.
Current release:
chatbot-v2-tool-systemActive feature branch:
work/v2-async-safety-and-docsStacked on:
mainRelease verification baseline:
75 test files passed
659 tests passed
Docker runtime reached READY
Manual local WhatsApp smoke passed
Manual Docker WhatsApp smoke passedDocumentation
Read these in order:
docs/installation.mdfor setup, configuration, testing, local runtime, Docker runtime, and troubleshooting.docs/production-handover.mdfor release handover, production checks, regression map, and branch cleanup.docs/async-job-workflow.mdfor the durable async job design and the rule that delayed replies require persisted jobs.docs/tool-configuration-guide.mdfor accepted tool JSON formats, routing metadata, schema options, access rules, and tool testing.docs/config-write-commands.mdfor v2.2 safe config mutation commands.docs/production-monitoring.mdfor v2.6 runtime health, Docker healthcheck, log rotation, and data backup/restore.docs/baileys-resilience.mdfor v2.7 reconnect/session resilience.docs/docker.mdfor Docker-specific notes.docs/npm-install.mdfor global CLI package checks.docs/connector-implementation-playbook.mdfor future connector guidance.
Quick local verification
npm install
npm run build
npm test
npm run cli -- doctor
npm run cli -- smoke
npm run cli -- config validate
npm run cli -- healthExpected release baseline:
75 test files passed
659 tests passedConfig write commands
The v2.2 branch adds safe writes for config/chatbot.config.json only:
npm run cli -- config set <path> <json-value>
npm run cli -- config unset <path>
npm run cli -- config backup
npm run cli -- config restore <backup-file>
npm run cli -- config diff
npm run cli -- config validateConfig writes create backups, validate before saving, reject unsafe paths, reject secret-like values, and leave config/tools.chatbot.json read-only for this milestone.
Production monitoring commands
The v2.6 branch adds health and runtime data operations:
npm run cli -- health
npm run cli -- health --quiet
bash scripts/backup-data.sh
bash scripts/restore-data.sh <backup-file> --yes
bash scripts/check-runtime.shDocker healthchecks now use the real CLI health command, and Compose includes bounded log files.
Baileys resilience
The v2.7 branch strengthens reconnect behavior:
- Bad sessions are treated as terminal instead of reconnect-looping.
- Terminal disconnects clear pending reconnect timers.
- Repeated reconnect schedules trigger a rapid-loop pause.
- Restart-required events still reconnect immediately unless the rapid-loop circuit breaker is active.
Run the targeted reconnect test:
npm test -- src/gateway/reconnect/__tests__/manager.test.tsLocal runtime
npm run start:workerWait for:
READY — processing messages nowDocker runtime
docker compose down
docker compose build --no-cache
docker compose run --rm wa-chatbot node dist/cli/index.js doctor
docker compose run --rm wa-chatbot node dist/cli/index.js config validate
docker compose run --rm wa-chatbot node dist/cli/index.js health
docker compose run --rm wa-chatbot node dist/cli/index.js smoke
docker compose upStop Docker:
docker compose downRelease-critical behavior
- Owner diagnostics and tool commands work in owner self-chat.
- Normal user chats receive normal user-facing replies.
- Natural-language current-information questions can route through tools when needed.
- Group replies follow configured activation rules.
- Docker persists auth, database, and media in
./dataand mounts config read-only from./config. - AI replies are sanitized before WhatsApp output so model preambles and tool artifacts are not sent to users.
- Health checks must not start WhatsApp, pair WhatsApp, or send messages.
- Reconnect logic must not loop forever after bad session, logout, device removal, connection replacement, forbidden, or multi-device mismatch.
Future work not included in the v2 release tag
- Arbitrary custom HTTP tool execution.
- npm publishing.
- Additional provider fallback tuning for weak web/news results.
- Custom tool connector system.
