No description
  • JavaScript 78.9%
  • HTML 21.1%
Find a file
2026-07-07 20:55:25 +07:00
auth_info pembaruan coding 2026-07-02 16:18:10 +07:00
data pembaruan coding 2026-07-02 16:18:10 +07:00
public upload 2026-07-02 12:27:18 +07:00
src di perbaiki tools oleh opencode dengan ai deepseek v4 flash 2026-07-07 20:52:04 +07:00
.gitignore di perbaiki tools oleh opencode dengan ai deepseek v4 flash 2026-07-07 20:52:04 +07:00
docker-compose.yaml mengatasi bagian stuck 2026-07-04 18:17:39 +07:00
package-lock.json upload 2026-07-02 12:27:18 +07:00
package.json di perbaiki tools oleh opencode dengan ai deepseek v4 flash 2026-07-07 20:52:04 +07:00
plain.txt upload 2026-07-02 12:27:18 +07:00
README.md perbaikan README.md untuk dokumentasi lebih jelas 2026-07-07 20:55:25 +07:00
struktur-tree.txt upload 2026-07-02 12:27:18 +07:00

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