https://github.com/shawshank725/whatsapp-bot
This project is a WhatsApp chatbot built with Java and Spring Boot, available in two versions: one using MySQL for relational data storage, and another using Firebase for real-time NoSQL storage. It supports doctor appointment booking and medicine ordering, integrates with the Meta WhatsApp Cloud API, and can be tested locally using ngrok.
https://github.com/shawshank725/whatsapp-bot
firebase firebase-database java mysql mysql-database ngrok spring-boot springboot whatsapp-api whatsapp-bot
Last synced: 3 months ago
JSON representation
This project is a WhatsApp chatbot built with Java and Spring Boot, available in two versions: one using MySQL for relational data storage, and another using Firebase for real-time NoSQL storage. It supports doctor appointment booking and medicine ordering, integrates with the Meta WhatsApp Cloud API, and can be tested locally using ngrok.
- Host: GitHub
- URL: https://github.com/shawshank725/whatsapp-bot
- Owner: shawshank725
- Created: 2025-08-09T20:01:53.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-09T20:23:05.000Z (11 months ago)
- Last Synced: 2025-08-19T21:12:27.885Z (11 months ago)
- Topics: firebase, firebase-database, java, mysql, mysql-database, ngrok, spring-boot, springboot, whatsapp-api, whatsapp-bot
- Language: Java
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WhatsApp Bot
This is a **WhatsApp Bot** built using **Java** and **Spring Boot**, with two separate implementations:
- **MySQL** (Relational Database)
- **Firebase** (NoSQL Database)
Both implementations offer the same functionalities but differ in the database management system used.
---
## 📌 Features
- Doctor appointment booking bot.
- Medicine ordering bot.
- Built using the **Meta for Developers** WhatsApp Cloud API.
- Two backend options:
- **MySQL** for relational data storage.
- **Firebase** for real-time NoSQL data storage.
- Tested locally using **ngrok** for webhook tunneling.
---
## ⚙️ Tech Stack
- **Java** (Spring Boot)
- **MySQL**
- **Firebase**
- **Meta WhatsApp Cloud API**
- **ngrok**
---
## 🔒 Sensitive Information
All personal credentials (phone number ID, access token, service account JSON for Firebase, etc.) have been **removed** from this repository.
To run this project, you will need to provide:
- Your own **phone number ID** and **access token** from the Meta developer portal.
- Your own **Firebase service account JSON** file (for Firebase version).
---
## 🚀 Running the Project
1. **Clone the repository**
```bash
git clone https://github.com/your-username/whatsapp-bot.git
cd whatsapp-bot
```
2. **Choose your implementation**
- **MySQL version** → Located in the MySQL project folder.
- **Firebase version** → Located in the Firebase project folder.
3. **Set up the database**
- **MySQL**:
Run the SQL scripts included in the MySQL project to create the required database and tables.
- **Firebase**:
Create a new Firebase project in the [Firebase Console](https://console.firebase.google.com/), obtain your **Service Account JSON**, and set up the required collections.
4. **Obtain WhatsApp Cloud API credentials**
- Go to the [Meta for Developers](https://developers.facebook.com/) dashboard.
- Create or open your **WhatsApp Business App**.
- Retrieve:
- **Phone Number ID**
- **Permanent Access Token**
- **Verify Token** (you choose this; must match in code and Meta dashboard)
- Note the **API endpoint** for sending messages.
5. **Configure your application**
- Add your credentials (Phone Number ID, Access Token, Verify Token, etc.) to the `application.properties` or environment variables for your chosen project.
- For Firebase: also add the path to your **Service Account JSON**.
6. **Set up ngrok for local testing**
- [Download ngrok](https://ngrok.com/download) and install it.
- Run ngrok to expose your Spring Boot port (default is 8080):
```bash
ngrok http 8080
```
- Copy the generated HTTPS URL.
7. **Configure webhook in Meta dashboard**
- In your WhatsApp app settings, set the **Callback URL** to the ngrok URL + your webhook path (e.g., `https://.ngrok.io/webhook`).
- Enter your **Verify Token** and click **Verify and Save**.
8. **Run the application**
```bash
./mvnw spring-boot:run
```
Or build and run the JAR:
```bash
./mvnw clean package
java -jar target/whatsapp-bot.jar
```
9. **Test the bot**
- Send a WhatsApp message to the phone number provided in your Meta developer dashboard.
- The bot should respond according to the appointment booking or medicine ordering flow.