https://github.com/codedbyasim/whatsapp-bot
A smart WhatsApp bot with tone-aware replies in Roman Urdu, group management tools, and LLM-powered features via Google Gemini API + Flask.
https://github.com/codedbyasim/whatsapp-bot
chatbot flask gemini-api nodejs python whatsapp-bot
Last synced: 3 months ago
JSON representation
A smart WhatsApp bot with tone-aware replies in Roman Urdu, group management tools, and LLM-powered features via Google Gemini API + Flask.
- Host: GitHub
- URL: https://github.com/codedbyasim/whatsapp-bot
- Owner: codedbyasim
- License: isc
- Created: 2025-08-26T12:12:12.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-26T12:27:50.000Z (10 months ago)
- Last Synced: 2025-08-26T16:37:27.544Z (10 months ago)
- Topics: chatbot, flask, gemini-api, nodejs, python, whatsapp-bot
- Language: JavaScript
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Tone-Aware WhatsApp Bot π€
A **sophisticated WhatsApp bot** designed to enhance group interactions and automate tasks.
It features **tone-aware replies**, **Roman Urdu language generation**, **group management commands**, and integrates a **Python Flask server** for advanced Large Language Model (LLM) capabilities using **Googleβs Gemini API**.
---
## β¨ Features
### π Tone & Fun
β Tone-aware replies (funny, chill, serious) in Roman Urdu
β `!joke` β Sends a short joke
β `!fact` β Provides an interesting fact
β `!roast @user` β Light-hearted roast for a tagged user
β `!quote` β Motivational or funny quote
### π₯ Group Management
β `!tagall` or `!tag [message]` β Tags all group members
β `!spam [@user] "" ` β Sends a message multiple times (max 20)
β `Stop @[BotName]` β Stops spam (only by initiator)
### π Utilities
β `!mood` β Analyzes recent group messages & reports mood
β `!news` β Fetches & summarizes todayβs top 5 news (Roman Urdu, News API key required)
β `!help` β Shows available commands
### πΈ Auto Reactions
* Replies with πΈ to "Good morning" and "Good night"
* Detects spam & roasts the sender
---
## ποΈ Architecture
**Hybrid setup:**
* **Node.js (main.js):** Handles WhatsApp communication, commands, and orchestrates requests
* **Python (hf_inference_server.py):** Runs a Flask server connected to **Google Gemini API** for LLM-powered tasks
---
## π Quick Start
### 1. Clone Repository
```bash
git clone https://github.com/codedbyasim/WhatsApp-Bot
cd WhatsApp-Bot
```
### 2. Install Dependencies
**Node.js:**
```bash
npm install
```
**Python:**
```bash
pip install Flask requests python-dotenv
```
### 3. Configure Environment Variables
Create a file named `.env` in the project root:
```ini
FIREBASE_PROJECT_ID=
FIREBASE_CLIENT_EMAIL=
FIREBASE_PRIVATE_KEY_PATH=
FIREBASE_STORAGE_BUCKET=
BOT_ID="1234567874@s.whatsapp.net"
# Authorized WhatsApp IDs
REHAN_ID=69510287589385@lid
SAAD_ID=12345678902@s.whatsapp.net
ASIM_ID=1234567878@s.whatsapp.net
# Target group/contact JID
CODE_ON_REMOTEJ_ID=120363403535865809@g.us
# Servers & APIs
PYTHON_INFERENCE_URL=http://localhost:5000
GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
NEWS_API_KEY="YOUR_NEWS_API_KEY"
```
---
## π Running the Bot
### Start Python Server
```bash
python hf_inference_server.py
```
(Starts Flask server on `http://localhost:5000`)
### Start Node.js Bot
```bash
node main.js
```
Scan the QR code in your terminal using **WhatsApp > Linked Devices**.
If successful, youβll see:
```
WhatsApp connection opened successfully!
```
---
## π¬ Example Usage
* `!help`
* `!joke`
* `!roast @SomeUser`
* `!tagall "Meeting in 5 minutes!"`
* `Good morning` β πΈ
---
## π Troubleshooting
β **Unauthorized to use this command**
β Ensure your WhatsApp ID is in `.env` under allowed users
β **Gemini API key is None**
β Check `.env` and restart `hf_inference_server.py`
β **Bot looping on "Good morning"**
β Update to latest `main.js` (bot ignores its own messages)
---
## π€ Contributing
Want to improve this bot? Fork the repo and submit a PR!
Some ideas for contributions:
* Add new fun commands (`!riddle`, `!shayari`)
* Add tone categories (angry, sarcastic, polite)
* Improve group management features
---
## π License
This project is licensed under the **ISC License**.