No description
- JavaScript 78.9%
- HTML 21.1%
| auth_info | ||
| data | ||
| public | ||
| src | ||
| .gitignore | ||
| docker-compose.yaml | ||
| package-lock.json | ||
| package.json | ||
| plain.txt | ||
| README.md | ||
| struktur-tree.txt | ||
WhatsApp Bot Express
WhatsApp Bot with Baileys, Express, Ollama AI & Web Dashboard.
Built with Node.js ≥20, Baileys (WhatsApp Web API), Express, Ollama (local LLM), and SQLite.
Features
- AI Chat — Natural language responses via Ollama (local LLM)
- Web Dashboard — QR login, status monitoring, send messages
- Commands —
/start,/daftar,/info,/help,/menu - Functions handled by AI:
getTime— Current time in any city (e.g., "jam berapa di Tokyo?")getWeather— Weather info (e.g., "cuaca di Bandung")getJoke— Random jokes (e.g., "ceritain joke programming")calculate— Math operations (e.g., "hitung 25 kali 4")searchWeb— Web search (e.g., "cari info tentang AI")getNews— Latest news (e.g., "berita saham Meta")getHelp— Help information
- Registration Flow — Users must register before using the bot
- Conversation State — Multi-step dialog (e.g., registration)
Prerequisites
- Node.js ≥20
- Ollama (optional, for AI features) — install from ollama.ai
- Pull a model:
ollama pull llama3.2:3b
Installation
# Clone
git clone https://git.pi.interka.my.id/alfatha/wa-bot.git
cd wa-bot
# Install dependencies
npm install
# Configure environment
cp .env .env.local # or edit .env directly
Configuration (.env)
PORT=3000
NODE_ENV=development
# Ollama
OLLAMA_URL=http://127.0.0.1:11434
OLLAMA_MODEL=llama3.2:3b
# OpenWeatherMap (optional, for real-time weather)
OPENWEATHER_API_KEY=your_key_here
Usage
# Start server
npm start
# Development mode (with auto-reload)
npm run dev
# Clean auth & data (re-login required)
npm run clean
Open http://localhost:3000 in your browser to access the dashboard.
Scan the QR code with WhatsApp to connect.
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /api/status |
WhatsApp connection status |
| GET | /api/qr |
Get QR code for login |
| POST | /api/send-text |
Send text message |
| POST | /api/send-image |
Send image message |
| POST | /api/logout |
Disconnect WhatsApp |
Project Structure
wa-bot/
├── src/
│ ├── app.js # Entry point
│ ├── config/
│ │ ├── database.js # SQLite database
│ │ ├── ollama.js # Ollama configuration
│ │ └── whatsapp.js # WhatsApp connection (Baileys)
│ ├── services/
│ │ ├── commandHandler.js # /start, /daftar, /info, /help
│ │ ├── functionRegistry.js # Function registration & lookup
│ │ ├── ollamaService.js # AI decision engine
│ │ ├── userService.js # User & conversation state management
│ │ └── whatsappService.js # Message handling & sending
│ ├── functions/
│ │ ├── calculate.js
│ │ ├── getHelp.js
│ │ ├── getJoke.js
│ │ ├── getNews.js
│ │ ├── getTime.js
│ │ ├── getWeather.js
│ │ └── searchWeb.js
│ └── routes/
│ └── index.js # Express routes
├── public/
│ └── index.html # Web dashboard
├── auth_info/ # WhatsApp session (auto-generated)
├── data/ # Runtime data
├── .env # Environment variables
├── docker-compose.yaml
├── package.json
└── README.md
Tech Stack
- Runtime: Node.js ≥20
- WhatsApp API: @whiskeysockets/baileys
- Framework: Express.js
- AI: Ollama (local LLM)
- Database: SQLite3
- Realtime: Socket.IO
- Dashboard: vanilla HTML + JS