This project implements a WhatsApp chatbot using Flask, integrated with OpenAI's GPT model and MongoDB for Retrieval-Augmented Generation (RAG). The bot can answer questions based on information stored in a MongoDB database.
This project implements a WhatsApp chatbot that uses Retrieval-Augmented Generation (RAG) to provide intelligent responses based on a knowledge base stored in a MongoDB database.
WhatsApp-Chatbot/
│
├── .env
├── .gitignore
├── README.md
├── requirements.txt
├── railway.json
│
├── src/
│ ├── __init__.py
│ ├── main.py
│ ├── config.py
│ ├── database/
│ │ ├── __init__.py
│ │ └── mongodb_client.py
│ ├── ai/
│ │ ├── __init__.py
│ │ ├── openai_client.py
│ │ └── rag_engine.py
│ ├── whatsapp/
│ │ ├── __init__.py
│ │ └── whatsapp_client.py
│ └── api/
│ ├── __init__.py
│ └── webhook.py
│
└── tests/
├── __init__.py
├── test_mongodb_client.py
├── test_openai_client.py
├── test_rag_engine.py
└── test_whatsapp_client.py
Clone the repository:
git clone https://github.com/yourusername/WhatsApp-Chatbot.git
cd WhatsApp-Chatbot
Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install the required packages:
pip install -r requirements.txt
Copy the .env.example
file to .env
and fill in your configuration details:
cp .env.example .env
Edit the .env
file with your specific configuration details:
To run the application locally:
python src/main.py
The application will start and listen on the port specified in your .env
file (default is 8080).
This project is configured for deployment on Railway. To deploy:
railway.json
.To run the tests:
python -m pytest tests/
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.