A WhatsApp-based auction management system for eFootball player auctions. This project consists of a Node.js WhatsApp bot that communicates with a Spring Boot REST API backend to manage player auctions, team balances, and bidding operations.
- WhatsApp Integration: Manage auctions directly through WhatsApp using Baileys library
- Player Auction Management: Sell players to teams with price tracking
- Team Balance Tracking: Monitor and query team balances
- Player Set Management: Organize players into sets for sequential auction
- Rollback Functionality: Undo the last transaction if needed
- Unsold Player Tracking: Mark and retrieve unsold players
- Real-time Updates: Get instant responses via WhatsApp
The project consists of two main components:
- Node.js WhatsApp Bot (
bot.js): Handles WhatsApp communication and command processing - Spring Boot Backend (
auctionBot/): REST API server managing auction logic, database operations, and business rules
- Node.js (v14 or higher)
- Java 17 or higher
- Maven 3.6+
- MySQL database
- WhatsApp account for bot authentication
git clone <repository-url>
cd efootball-whatsapp-botNavigate to the backend directory:
cd auctionBot- Create a MySQL database named
efootball:
CREATE DATABASE efootball;- Update database credentials in
src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/efootball
spring.datasource.username=your_username
spring.datasource.password=your_password# Build the project
mvn clean install
# Run the Spring Boot application
mvn spring-boot:runThe backend will start on http://localhost:8080
Navigate back to the root directory:
cd ..npm installnpm startOn first run, you'll see a QR code in the terminal. Scan it with WhatsApp to authenticate the bot.
All commands are prefixed with ! and sent via WhatsApp:
| Command | Description | Example |
|---|---|---|
!sell <player> <price>M <team> |
Sell a player to a team | !sell Messi 50M Barcelona |
!balance <team_name> |
Check balance of a specific team | !balance Barcelona |
!allBalance |
View balance of all teams | !allBalance |
!view <team_name> |
View all players of a team | !view Barcelona |
!next |
Get the next player in the auction set | !next |
!rollback |
Undo the last transaction | !rollback |
!addAll |
Add multiple players (newline-separated) | !addAll\nPlayer1\nPlayer2 |
!unsold <player_name> |
Mark a player as unsold | !unsold PlayerName |
!getUnsold |
Get list of all unsold players | !getUnsold |
!commands |
View all available commands | !commands |
Edit auctionBot/src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/efootball
spring.datasource.username=root
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=updateThe bot connects to the backend API at http://localhost:8080. If you need to change this, modify the API URLs in bot.js.
efootball-whatsapp-bot/
βββ bot.js # Main WhatsApp bot file
βββ package.json # Node.js dependencies
βββ auth/ # WhatsApp authentication files (auto-generated)
β
βββ auctionBot/ # Spring Boot backend
βββ src/
β βββ main/
β βββ java/
β β βββ com/example/auctionbot/
β β βββ controller/
β β β βββ BotController.java # REST API endpoints
β β βββ service/
β β β βββ PlayerService.java # Player business logic
β β β βββ TeamService.java # Team business logic
β β βββ model/
β β β βββ Player.java # Player entity
β β β βββ Team.java # Team entity
β β βββ repository/
β β β βββ PlayerRepo.java # Player data access
β β β βββ TeamRepo.java # Team data access
β β βββ DTO/
β β βββ Data.java # Request DTO
β β βββ Message.java # Response DTO
β βββ resources/
β βββ application.properties # Configuration
βββ pom.xml # Maven dependencies
The Spring Boot backend exposes the following REST endpoints:
| Method | Endpoint | Description |
|---|---|---|
| POST | /auction/bid |
Process a player sale |
| GET | /auction/balance?team={name} |
Get team balance |
| GET | /auction/getAllBalance |
Get all team balances |
| GET | /auction/getPlayers/{team} |
Get team's players |
| GET | /auction/next |
Get next player in set |
| GET | /auction/rollback |
Rollback last transaction |
| POST | /auction/addAll |
Add multiple players |
| GET | /auction/unsold/{name} |
Mark player as unsold |
| GET | /auction/getUnsold |
Get unsold players |
| GET | /auction/allCommands |
Get all available commands |
- @whiskeysockets/baileys: WhatsApp Web API library
- axios: HTTP client for API requests
- qrcode-terminal: QR code generation for authentication
- @hapi/boom: HTTP error handling
- Spring Boot 3.5.3: Java framework
- Spring Data JPA: Database abstraction layer
- MySQL: Relational database
- Lombok: Java boilerplate reduction
- Maven: Dependency management
The bot uses WhatsApp Web authentication:
- On first run, a QR code is displayed in the terminal
- Scan the QR code with your WhatsApp mobile app
- Authentication files are saved in the
auth/directory - Subsequent runs will use saved credentials automatically
Note: If you get logged out, delete the auth/ directory and scan the QR code again.
- Ensure the backend is running on port 8080
- Check if the
auth/directory exists and has valid credentials - Delete
auth/folder and re-authenticate if needed
- Verify MySQL is running
- Check database credentials in
application.properties - Ensure the
efootballdatabase exists
- Verify the backend is running:
http://localhost:8080 - Check backend logs for detailed error messages
- Ensure database tables are created (Hibernate will auto-create them)
- The bot processes only text messages starting with
! - Player prices should end with
M(e.g.,50M) - The auction set system processes players in batches of 10
- Rollback only works for the most recent transaction
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is open source and available for personal use.
Happy Auctioning! β½