npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

whatsapp-bot-api

v1.0.1

Published

WhatsApp Bot API server with multi-account support

Readme

WhatsApp Bot API 🤖

Multi-account WhatsApp automation platform with n8n integration.

🚀 Quick Start

با Docker (توصیه می‌شود)

# راه‌اندازی فوری
docker-compose up -d

# یا با اسکریپت
./deploy.sh

📖 راهنمای کامل Docker

Manual Installation

# نصب dependencies
pnpm install

# اجرا
pnpm start

# اضافه کردن اکانت اول
curl -X POST http://localhost:3000/api/accounts/add \
  -H "Content-Type: application/json" \
  -d '{"name": "account1", "webhookUrl": "https://your-webhook.com"}'

📚 مستندات


✨ Features

  • ✅ Multi-account WhatsApp support
  • ✅ REST API for sending messages
  • ✅ Webhook for receiving messages
  • ✅ Dynamic account management (add/remove accounts)
  • ✅ QR code retrieval as Data URL
  • ✅ n8n custom node integration
  • ✅ Docker ready
  • ✅ Production ready with Nginx

🔌 API Endpoints

Message Operations

  • POST /api/send - ارسال پیام

Account Management

  • GET /api/accounts - لیست اکانت‌ها
  • POST /api/accounts/add - اضافه کردن اکانت جدید
  • GET /api/accounts/:name/qr - دریافت QR code
  • DELETE /api/accounts/:name - حذف اکانت

Webhook

  • POST /webhook - دریافت پیام‌های دریافتی

Health Check

  • GET /health - بررسی وضعیت سرور

🛠️ Development

# Install
pnpm install

# Development mode
pnpm dev

# Build TypeScript
pnpm build

# Production
pnpm start

🐳 Docker Commands

# Development
docker-compose up -d

# Production (with Nginx)
docker-compose -f docker-compose.prod.yml up -d

# Logs
docker-compose logs -f

# Stop
docker-compose down

📊 مثال استفاده

ارسال پیام با curl

curl -X POST http://localhost:3000/api/send \
  -H "Content-Type: application/json" \
  -d '{
    "account": "account1",
    "to": "989123456789",
    "message": "سلام از Bot API!"
  }'

اضافه کردن اکانت جدید

curl -X POST http://localhost:3000/api/accounts/add \
  -H "Content-Type: application/json" \
  -d '{
    "name": "account2",
    "webhookUrl": "https://your-n8n.com/webhook/whatsapp"
  }'

دریافت QR Code

curl http://localhost:3000/api/accounts/account2/qr

🔧 Configuration

دیگر نیازی به فایل config نیست! همه چیز از طریق API مدیریت می‌شود:

# اضافه کردن اکانت
curl -X POST http://localhost:3000/api/accounts/add \
  -H "Content-Type: application/json" \
  -d '{
    "name": "account1",
    "webhookUrl": "https://your-webhook-url.com"
  }'

# لیست اکانت‌ها
curl http://localhost:3000/api/accounts

# حذف اکانت
curl -X DELETE http://localhost:3000/api/accounts/account1

تنظیمات اختیاری از طریق Environment Variables:

PORT=3000           # پورت سرور
NODE_ENV=production # محیط اجرا

🌐 استفاده با n8n

  1. نصب custom node:
npm install @mmkhak/n8n-nodes-whatsapp
  1. Restart n8n

  2. ایجاد workflow جدید و استفاده از "WhatsApp" nodes


🔒 Security

  • API Key authentication (اختیاری)
  • Rate limiting با Nginx
  • HTTPS support
  • Webhook signature verification

🐛 Troubleshooting

QR Code نمایش داده نمی‌شود

curl http://localhost:3000/api/accounts/YOUR_ACCOUNT/qr

Session قطع می‌شود

مطمئن شوید baileys_auth_* فولدرها volume شده‌اند در Docker

Port در حال استفاده است

# تغییر port در config.json یا docker-compose.yml
"port": 8080

📦 Project Structure

whatsapp-bot-api/
├── src/
│   └── index.ts          # Main application
├── config.json           # Configuration
├── Dockerfile            # Docker image
├── docker-compose.yml    # Docker Compose
├── nginx.conf            # Nginx config
├── deploy.sh             # Deployment script
└── package.json          # Dependencies

🤝 Contributing

Contributions are welcome!


📝 License

MIT


🔗 Links


Made with ❤️ by Milad