Skip to content

About

This is a Go-based WhatsApp bot built using whatsmeow. It allows sending messages via WhatsApp Web and supports SQLite-based session storage.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

63 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp Bot 📩

This is a Go-based WhatsApp bot built using whatsmeow. It allows sending messages via WhatsApp Web and supports SQLite-based session storage.


🚀 Features

  • ✅ QR Code Authentication for WhatsApp Web.
  • ✅ Send Messages to WhatsApp users.
  • ✅ SQLite Storage for session persistence.
  • ✅ Docker Support for containerized deployment.

⚙️ Installation & Setup

1️⃣ Prerequisites

  • Go (≥ 1.23.5) installed: Download
  • Docker installed: Install
  • WhatsApp account for authentication

2️⃣ Clone the Repository

git clone https://github.com/ozgen/whatsappbot.git
cd whatsappbot

3️⃣ Install Dependencies

go mod tidy

4️⃣ Run the Bot

go run cmd/main.go
  • This will generate a QR Code (whatsapp_qr.png).
  • Open WhatsApp Web > Linked Devices, scan the QR code.
  • Copy code in the log and generate qr code image with this website https://www.qr-code-generator.com

🐳 Running with Docker

1️⃣ Build & Run the Container

docker build -t whatsappbot:v1 .
docker run -d --name whatsappbot -p 9090:9090 -v "$(pwd)/data:/app/data" whatsappbot

2️⃣ Using Docker Compose

docker-compose up -d

Ensure your docker-compose.yml includes the volume:

version: '3.1'
services:
  whatsappbot:
    image: whatsappbot:v1
    platform: linux/amd64
    ports:
      - "9090:9090"
    volumes:
      - ./data:/app/data

🔧 API Usage (Send Message)

Once the bot is running, you can send messages via API:

Request

curl -X POST "http://localhost:9090/send-message" \
     -H "Content-Type: application/json" \
     -d '{"phone": "491234567890", "message": "123456"}'

Response

{
  "message": "Message sent successfully"
}

🛠️ Troubleshooting

1️⃣ QR Code Not Scanning

  • Ensure WhatsApp Web is open and working.
  • Delete whatsapp_qr.png and restart the bot.

2️⃣ Docker Error: GLIBC_2.34 not found

If you get glibc issues, change Dockerfile base image:

FROM golang:1.23.5 AS builder

Rebuild:

docker build --no-cache -t whatsappbot:v1 .

3️⃣ failed to initialize database: CGO_ENABLED=0

  • The bot requires CGO for SQLite.
  • Rebuild without CGO_ENABLED=0:
CGO_ENABLED=1 go build -o whatsappbot ./cmd/main.go

🔗 References


About

This is a Go-based WhatsApp bot built using whatsmeow. It allows sending messages via WhatsApp Web and supports SQLite-based session storage.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages