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

Published: (February 15, 2026 at 09:34 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

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         │
└──────────────────┴───────────────────────────┘

Tech Stack

LayerTechnology
APINestJS 10 + Fastify
AdminNext.js 14 + Tailwind CSS
DatabasePostgreSQL 16 + Prisma ORM
QueueRedis 7 + BullMQ
WhatsAppwhatsapp‑web.js / Baileys
AuthJWT (access + refresh tokens)
RealtimeSocket.IO
ContainerDocker + 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

The API runs on port 3333 with Swagger docs, and the 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!"
  }'

SDK Support

Official SDKs are available for three languages. Example for TypeScript:

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!',
});

Contributing

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

GitHub:

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.

0 views
Back to Blog

Related posts

Read more »

Preface

Motivation I wanted to record my studies to have consistency. Since I don't directly learn building projects from my CS program, I want to be an expert in my a...