whatsagent
v0.1.1
Published
WhatsApp-only agent backend built on Nexusbert architecture.
Readme
WhatsAgent
WhatsAgent is a WhatsApp-only conversational automation platform built on the Nexusbert vision.
This repository starts with a production-oriented design for v1:
- WhatsApp Cloud API webhook ingestion
- Conversation processing and agent orchestration
- Outbound delivery with 24-hour session policy handling
- Durable storage, retries, and observability
Design Documents
docs/architecture/whatsagent-v1.md- end-to-end system architecture and runtime flowdocs/architecture/data-model.md- relational schema for conversations, messages, and delivery statedocs/architecture/api-contracts.md- internal API contracts and webhook shapesdocs/architecture/implementation-plan.md- phased build plan with acceptance criteriadocs/architecture/service-boundaries.md- repository layout and service responsibilitiesdocs/architecture/jaspers-merge-guide.md- what was ported from Jasper sample
Scope
This version intentionally focuses on WhatsApp only. No multi-channel abstractions are required for v1.
Quick Start
- Copy
.env.exampleto.envand fill values. - Install dependencies:
npm install
- Run tests (default memory drivers):
npm test
- Start services:
npm run dev:webhooknpm run dev:orchestratornpm run dev:deliverynpm run dev:agent
Production Infra Mode
- Start infrastructure:
npm run infra:up
- Set
.env:DB_DRIVER=postgresQUEUE_DRIVER=redis
- Apply schema:
npm run db:migrate
- Start services in separate terminals:
npm run dev:webhooknpm run dev:orchestratornpm run dev:delivery
This mode uses PostgreSQL and Redis (streams) so services can run as separate processes with durable queue consumption.
One-Command Dev Stack
npm run dev:stack
This command:
- starts Docker infrastructure (Postgres + Redis),
- applies database schema migration,
- starts webhook, orchestrator, delivery, and agent services together.
Use Ctrl+C to stop all services started by the stack command.
Security and Runtime Notes
- Internal endpoints under
/internal/*are protected whenINTERNAL_API_KEYis set.- send header:
x-internal-api-key: <your-key>
- send header:
- Webhook route has basic IP rate limiting.
- tune with
WEBHOOK_RATE_LIMIT_PER_MINUTE
- tune with
- Redis stream consumers can be grouped/tuned with:
QUEUE_CONSUMER_GROUPQUEUE_CONSUMER_NAME
Jasper Alignment (WhatsApp API)
WhatsAgent now mirrors Jasper's strongest WhatsApp API pattern in delivery:
- send optional read receipt + typing indicator before reply,
- send message through
/{phone_number_id}/messagesGraph endpoint, - support text, interactive, template, and raw request-body passthrough payloads.
Config:
WA_SEND_READ_BEFORE_REPLY=true|falsetoggles read+typing pre-send behavior.
Meta WhatsApp Env Mapping
These are the key variables that align with Meta WhatsApp Cloud API:
WA_ACCESS_TOKEN-> temporary/permanent system user access tokenWA_PHONE_NUMBER_ID-> WhatsApp phone number ID used for/{phone_number_id}/messagesWA_APP_SECRET-> app secret used for webhook signature verification (X-Hub-Signature-256)WA_VERIFY_TOKEN-> your custom webhook verify token forGET /webhookWA_API_BASE_URL-> Graph API base (https://graph.facebook.com/v22.0by default)
Optional but commonly tracked in Meta setup:
APP_ID/WA_APP_ID(not required by runtime send path)WABA_ID(not required by runtime send path)
Installable NPM Package
Local install test
- Build package:
npm run build
- Link globally:
npm link
- Use CLI:
whatsagent helpwhatsagent initwhatsagent docswhatsagent migratewhatsagent start all
Publish to npm
- Ensure package name availability (
whatsagentmay already be taken). - Make sure you are on the branch/commit to publish.
- Run full checks:
npm run typechecknpm test
- Build dist artifacts:
npm run build
- Validate package contents:
npm pack --dry-run
- Bump version:
npm version patch- or
npm version minor - or
npm version major
- Login:
npm login
- Publish:
npm publish --access public
- Verify from clean shell:
npm i -g whatsagentwhatsagent help
Consumers can then install with:
npm i -g whatsagent(global CLI)- or
npm i whatsagentand run withnpx whatsagent ...
Post-install flow
After install, users can run:
whatsagent help- list commands.whatsagent docs- launch local docs athttp://localhost:4173.whatsagent init- create.envin current folder.- configure
.envwith Meta WhatsApp keys. whatsagent migratethenwhatsagent start all.
Operations
docs/operations/runbook.md- incident and replay proceduresdocs/operations/launch-checklist.md- launch gate checklist
