This project is a complete, professional, and extensible platform for creating and managing multiple autonomous WhatsApp agents based on AI. Each agent is linked to a distinct user (multi-client) and behaves like a human personal assistant.
- Multi-Agent & Multi-Client: Each client can connect their own WhatsApp account via QR Code. New agents can be added simply by editing the
.envfile. - Intelligent Behavior: Agents introduce themselves, adopt a specific personality via system prompts, and handle conversations naturally.
- Multi-LLM Support: Easily switch between AI providers like Gemini (default), OpenAI, and DeepSeek.
- Safety & Anti-Blocking: Implements rate limiting and human-like delays to minimize the risk of being blocked by WhatsApp.
- Human Handover: Agents can detect when a user wants to speak to the owner and can trigger a handover process.
- SaaS Ready: Comes with a complete React dashboard for managing agents, viewing conversations, and checking stats.
- API-Driven: A Node.js/Express backend serves the frontend and manages the core WhatsApp logic.
The project is a monorepo composed of two main parts:
-
Backend (Node.js):
src/core: Manages the WhatsApp connections using@whiskeysockets/baileys. TheAgentManagerorchestrates multipleWhatsappClientinstances.src/ai: Handles interaction with Large Language Models (LLMs). Thellm-routerselects the appropriate provider, and theMemoryManagermaintains conversation context.src/api: An Express.js server that provides a REST API for the frontend to interact with the agents (e.g., fetch QR codes, get status).sessions/: Directory where WhatsApp session data is stored, allowing agents to reconnect without re-scanning the QR code.
-
Frontend (React):
dashboard/: A complete React application built with TypeScript and Tailwind CSS.pages/: Contains the main views like Login, Dashboard, and Agent Details.components/: Reusable UI components for displaying QR codes, stats, conversations, etc.services/mockApi.ts: A mock API is used for frontend development, simulating backend responses.
- Node.js (v18 or higher)
- npm or yarn
-
Navigate to the backend directory and install dependencies:
# (From the project root) npm install -
Create an environment file: Copy the example file to create your own configuration.
cp .env.example .env
-
Configure your agents and API keys: Open the
.envfile and:- Add your
GEMINI_API_KEY. - Configure the details for
AGENT_1. You can add more agents (AGENT_2,AGENT_3, etc.) by following the same pattern.
- Add your
-
Start the backend server:
npm run dev
The server will start, and you will see logs indicating that it is trying to connect the agents. The first time you run it, you'll need to scan a QR code.
The frontend is self-contained within this project and requires no separate build step. Simply open index.html in a browser with a local web server, or use the integrated development environment.
- After starting the backend, the API is available at
http://localhost:3001. - The frontend dashboard is designed to call an endpoint like
http://localhost:3001/api/qr/agent-001(whereagent-001is the ID from your.envfile). - This endpoint will return a QR code image. Scan this code with your WhatsApp mobile app (
Settings > Linked Devices > Link a Device). - Once scanned, the backend will log that the agent is connected, and the session files will be saved in the
sessions/agent-001/directory. The agent is now live!
This project is licensed under the MIT License. See the LICENSE.md file for details.