A WhatsApp bot integration for AzizChatbot - allowing users to interact with the AI chatbot directly through WhatsApp. Built with Go and the WhatsApp Web API.
- WhatsApp Web Integration: Uses whatsmeow library for WhatsApp Web API
- QR Code Authentication: Easy login via QR code scanning
- Rate Limiting: Redis integration for message rate limiting
- Docker Support: Multi-stage build for optimized container size
- Language: Go 1.23
- WhatsApp API: whatsmeow
- Database: PostgreSQL (via pgx driver)
- Session Management: Redis
- QR Code: qrterminal
- Environment: godotenv
- Go 1.23 or higher
- PostgreSQL database
- Redis server
- AI service running (see azizchatbot-ai)
-
Clone the repository:
git clone https://github. com/AzizChatbot/azizchatbot-whatsapp-bot.git cd azizchatbot-whatsapp-bot -
Install dependencies:
go mod download
-
Create a
.envfile based on. env.example:REDIS_URL="redis://localhost:6379" AI_URL="http://localhost:5000" DB_URL="postgresql://user:password@localhost/whatsapp_bot"
-
Run the application:
go run main.go
-
Scan the QR code with WhatsApp to authenticate.
-
Build the Docker image:
docker build -t azizchatbot-whatsapp-bot . -
Run the container:
docker run -it --env-file .env azizchatbot-whatsapp-botNote: For QR code scanning, run the container in interactive mode (
-it) to see the QR code in the terminal.
azizchatbot-whatsapp-bot/
├── main.go # Application entry point
├── lib/
│ └── msgHandler/ # Message handling logic
├── go.mod # Go module definition
├── go. sum # Dependency checksums
├── Dockerfile # Multi-stage Docker build
└── . env. example # Environment variables template
- Initialization: The bot connects to WhatsApp Web using stored credentials or prompts for QR code login
- Session Storage: Device credentials are stored in PostgreSQL for persistent sessions
- Message Handling: Incoming messages are processed and sent to the AI service
- Response: AI responses are sent back to the user via WhatsApp
- Group Protection: Bot automatically leaves any group it's added to
This project is open source and available under the MIT License.
Made with ❤️ for King Abdulaziz University