DEV Community

Rizky Bachtiar Irwanto
Rizky Bachtiar Irwanto

Posted on

Building MultiWA: An Open-Source Self-Hosted WhatsApp API Gateway

Why I Built MultiWA

I needed WhatsApp automation for a business application, but the official WhatsApp Cloud API comes with per-message pricing and requires Meta hosting. Existing open-source alternatives were either limited to a single session or lacked proper admin tooling.

So I built MultiWA — a fully self-hosted, multi-session WhatsApp API gateway with an admin dashboard, visual automation builder, and AI-powered auto-replies.

What is MultiWA?

MultiWA is an open-source WhatsApp Business API Gateway that lets you:

  • Connect multiple WhatsApp numbers through a single unified API
  • Choose between whatsapp-web.js and Baileys engine adapters
  • Manage everything through a modern Admin Dashboard
  • Build automations with a visual drag-and-drop flow builder
  • Set up AI-powered auto-replies using OpenAI or Google AI
  • Send messages via REST API with official SDKs for TypeScript, Python, and PHP

Architecture

┌──────────────────────────────────────────────┐
│               Nginx (SSL/Proxy)               │
├──────────────────┬───────────────────────────┤
│  Admin (Next.js) │     API (NestJS/Fastify)   │
│  Port 3001       │     Port 3000              │
│                  │  WhatsApp Engine Adapters   │
│                  │  ├─ whatsapp-web.js         │
│  Worker (BullMQ) │  └─ Baileys                │
│                  │  PostgreSQL │ Redis         │
└──────────────────┴───────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

Tech Stack

Layer Technology
API NestJS 10 + Fastify
Admin Next.js 14 + Tailwind CSS
Database PostgreSQL 16 + Prisma ORM
Queue Redis 7 + BullMQ
WhatsApp whatsapp-web.js / Baileys
Auth JWT (access + refresh tokens)
Realtime Socket.IO
Container Docker + Docker Compose

Key Features

Multi-Session Management

Connect unlimited WhatsApp accounts, each running independently with its own QR code authentication, status monitoring, and message routing.

Pluggable Engine Adapters

MultiWA uses an adapter pattern for WhatsApp engines. Currently supports whatsapp-web.js (Chromium-based) and Baileys (lightweight, no browser). You can switch engines per session without changing your application code.

Visual Automation Builder

Create message automation flows with a drag-and-drop interface. Define triggers (keyword match, regex, webhook), conditions, and actions (reply, forward, API call) — all without writing code.

AI Knowledge Base

Upload documents and let AI handle customer inquiries automatically. Supports both OpenAI and Google AI as providers. The system uses RAG (Retrieval-Augmented Generation) to find relevant answers from your knowledge base.

Enterprise Features

  • JWT authentication with refresh tokens
  • API key management with scoping and expiration
  • Webhook subscriptions for real-time event notifications
  • Scheduled messages and broadcast
  • Audit trail and analytics dashboard
  • GDPR-compliant data export and deletion

Quick Start with Docker

git clone https://github.com/ribato22/MultiWA.git
cd MultiWA
cp .env.production.example .env
docker compose -f docker-compose.production.yml up -d
Enter fullscreen mode Exit fullscreen mode

That's it. API runs on port 3333 with Swagger docs, Admin dashboard on port 3001.

Send Your First Message

curl -X POST http://localhost:3333/api/v1/messages/send \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "profile-uuid",
    "to": "6281234567890",
    "message": "Hello from MultiWA!"
  }'
Enter fullscreen mode Exit fullscreen mode

SDK Support

Official SDKs are available for three languages:

import { MultiWA } from '@multiwa/sdk';

const client = new MultiWA({
  baseUrl: 'http://localhost:3000',
  apiKey: 'your-api-key',
});

await client.messages.send({
  profileId: 'profile-uuid',
  to: '6281234567890',
  message: 'Hello!',
});
Enter fullscreen mode Exit fullscreen mode

Contributing

MultiWA is MIT-licensed and open for contributions. Whether it's bug reports, feature requests, or pull requests — everything is welcome.

GitHub: https://github.com/ribato22/MultiWA

If you have any questions about the architecture or need help setting it up, feel free to ask in the comments or open a discussion on GitHub.

Top comments (0)