lmskin
MCP Serverlmskinpublic

whatsapp

使用 React、Node.js、PostgreSQL 和 WhatsApp API 构建的全栈企业消息管理工具。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
JavaScript
Language
-
License

About This Server

使用 React、Node.js、PostgreSQL 和 WhatsApp API 构建的全栈企业消息管理工具。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

📦 WhatsApp-Integrated Internal System (React + Node.js + PostgreSQL + REST + WhatsApp API)

🚀 Overview

This project connects WhatsApp Cloud API with your internal business database using a modern full-stack setup:

  • Frontend: React (admin dashboard)
  • Backend: Node.js + Express (REST API)
  • Database: PostgreSQL
  • Messaging: WhatsApp Cloud API (Meta)
  • Tunnel: ngrok for exposing local webhooks
  • Socket.IO: Real-time communication

🛠 Tech Stack

LayerTechnologyPurpose
FrontendReactAdmin UI (view and send messages)
BackendNode.js + ExpressREST API, message parsing, DB access
DatabasePostgreSQLStores user, message, and order data
API GatewayRESTful APICommunication between frontend/backend
MessagingWhatsApp Cloud APIHandle user messages from WhatsApp
NLPWhatsApp MCP ServerNatural language processing
TunnelngrokExpose local webhook to Meta's servers
WebSocketsSocket.IOReal-time updates between client/server

📁 Folder Structure

project-root/
├── client/                 # React frontend
│   ├── public/
│   └── src/
│       ├── components/
│       ├── pages/
│       ├── services/
│       ├── App.js
│       └── index.js
├── server/                 # Node.js backend
│   ├── controllers/
│   ├── routes/
│   ├── models/
│   ├── services/
│   ├── config/
│   └── app.js
├── db/                     # PostgreSQL schema/migrations
├── config/                 # Configuration files
│   ├── .env-example
│   ├── db-config.txt
│   ├── mcp-flow.txt
│   └── ngrok.yml
├── scripts/                # Setup and start scripts
│   ├── setup/              # Setup scripts
│   │   ├── setup-database.bat/.ps1/.sh
│   │   ├── setup-mcp.bat/.sh
│   │   └── create-env.bat/.ps1
│   └── start/              # Start scripts
│       ├── start-all-services.bat/.ps1
│       ├── start-ui.bat
│       ├── start-with-ngrok.bat/.ps1/.sh
│       └── start-client.js
├── whatsapp-mcp-server/    # MCP Server implementation
│   ├── src/
│   ├── tests/
│   ├── pyproject.toml
│   └── Dockerfile
├── system-flowchart.md     # System architecture flowchart  
├── .env-example            # Environment variables template
├── package.json            # Root package.json with scripts
└── README.md

📜 Available npm Scripts

For convenience, this project provides several npm scripts to help you set up and run the application. You can run them with npm run <script-name>:

Script NameDescription
startStart the production server
serverStart only the backend server
clientStart only the React frontend
install-serverInstall dependencies for server only
install-clientInstall dependencies for client only
install-allInstall dependencies for root, server, and client
devStart both server and client for development
buildBuild the React frontend for production
setup-mcpSet up the MCP server (Linux/macOS)
setup-mcp-winSet up the MCP server (Windows)
start-mcpStart the MCP server
dev-with-mcpStart server, client, and MCP server together
start-uiStart the UI using the batch script
start-allStart all services using batch script
start-all-psStart all services using PowerShell script
start-ngrokStart ngrok tunnel using batch script
start-ngrok-psStart ngrok tunnel using PowerShell script
start-ngrok-shStart ngrok tunnel using shell script (Linux/macOS)
create-envCreate .env file using batch script
create-env-psCreate .env file using PowerShell script
setup-dbSet up database using batch script
setup-db-psSet up database using PowerShell script
setup-db-shSet up database using shell script (Linux/macOS)
migrateRun database migrations

⚙️ Setup Instructions

1. Install Prerequisites

  • Node.js (v18+)
  • PostgreSQL
  • ngrok
  • Python (v3.8+ for MCP server)
  • WhatsApp Cloud API access via Meta Developer Console

2. Configure .env

# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_db
DB_USER=postgres
DB_PASS=your_password

# WhatsApp Cloud API
WA_PHONE_NUMBER_ID=your_phone_id
WA_ACCESS_TOKEN=your_meta_access_token
WA_API_VERSION=v17.0

# Server
PORT=3001

# Socket.IO
SOCKET_PORT=4000

3. Set Up the Database

  1. Create a PostgreSQL database:
CREATE DATABASE whatsapp_db;
  1. Run the database setup script using one of these commands:
# Windows Command Prompt
npm run setup-db

# Windows PowerShell
npm run setup-db-ps

# Linux/macOS
npm run setup-db-sh
  1. Apply database migrations:
npm run migrate
  1. Create a .env file in the root directory with your database and WhatsApp credentials:
# Windows Command Prompt
npm run create-env

# Windows PowerShell
npm run create-env-ps

4. Start PostgreSQL

Set up your schema:

-- db/schema.sql
CREATE TABLE messages (
  id SERIAL PRIMARY KEY,
  wa_user_id TEXT NOT NULL,
  content TEXT,
  timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  order_number TEXT,
  status TEXT,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

5. Install Dependencies

Install all dependencies with a single command:

npm run install-all

6. Start Backend & Frontend

You can start all services with a single command:

# Windows Command Prompt
npm run start-all

# Windows PowerShell
npm run start-all-ps

Or start individual components:

Backend:

npm run server

Frontend:

npm run client

Development Mode (both):

npm run dev

With MCP Server:

npm run dev-with-mcp

7. Expose Localhost with ngrok

Install ngrok:

npm install -g ngrok

Authenticate:

ngrok config add-authtoken <YOUR_NGROK_AUTH_TOKEN>

Expose port 3001 using the provided script:

# Windows Command Prompt
npm run start-ngrok

# Windows PowerShell
npm run start-ngrok-ps

# Linux/macOS
npm run start-ngrok-sh

Copy the generated HTTPS URL, e.g.:

https://abc123.ngrok.io

8. Register Webhook in Meta App

In your WhatsApp App Settings:

  • Webhook URL:
    https://abc123.ngrok.io/webhook/whatsapp
  • Verify Token:
    Match the one in your .env or Express logic
  • Subscribe to the messages field

📡 WhatsApp Message Flow

Please see the system-flowchart.md file for a detailed diagram of how messages flow through the system.

🚀 Key Features

  • Two-way Communication: Send and receive WhatsApp messages
  • Admin Dashboard: View and manage conversations
  • Order Tracking: Allow customers to check order status via WhatsApp
  • Automated Responses: Configure auto-replies for common questions
  • Real-time Updates: Socket.IO integration for live updates
  • Natural Language Processing: Optional MCP server for advanced message understanding
  • Multi-platform Support: Run on Windows, macOS, or Linux

🧩 Components

Frontend (React)

  • Admin dashboard for viewing and responding to WhatsApp messages
  • Message history and user management
  • Real-time updates with Socket.IO
  • Order management interface

Backend (Node.js + Express)

  • REST API for frontend communication
  • WhatsApp Cloud API integration
  • Message processing and routing
  • Database interactions
  • WebSocket server for real-time updates

MCP Server (Python)

  • Natural Language Processing for message understanding
  • Intent detection and entity extraction
  • Response generation based on user queries

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Quick Start

1

Clone the repository

git clone https://github.com/lmskin/whatsapp
2

Install dependencies

cd whatsapp
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerlmskin
Repowhatsapp
LanguageJavaScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation