WhatsApp Medical Chatbot API
This is a FastAPI-based API for a WhatsApp medical chatbot that provides various healthcare services.
Features
- WhatsApp integration for chat-based interactions
- Consultation booking with healthcare professionals
- OTC drug purchase capabilities
- Symptom checking and clinical triage
- Doctor report generation
- Voice note processing for audio input
- Monitoring with Grafana, Prometheus, Loki, and Promtail
Tech Stack
- Backend: Python 3.11+ with FastAPI
- Database: SQLite with SQLAlchemy ORM
- Authentication: JWT-based authentication
- Documentation: OpenAPI (Swagger UI and ReDoc)
- Monitoring: Prometheus, Grafana, Loki, and Promtail
- Deployment: Docker, Docker Compose, and Kubernetes
Getting Started
Prerequisites
- Python 3.11+
- Docker and Docker Compose (for containerized deployment)
Installation
-
Clone the repository:
git clone <repository-url> cd whatsapp-medical-chatbot-api
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file based on.env.example
:cp .env.example .env
Then edit the
.env
file to set the required environment variables.
Running the Application
Using Python
uvicorn main:app --reload
Using Docker
docker-compose up -d
Environment Variables
The application requires the following environment variables:
APP_NAME
: Name of the applicationAPI_V1_PREFIX
: Prefix for API v1 endpointsSECRET_KEY
: Secret key for JWT token generationACCESS_TOKEN_EXPIRE_MINUTES
: JWT token expiration time in minutesWHATSAPP_API_URL
: WhatsApp API URLWHATSAPP_API_TOKEN
: WhatsApp API authentication tokenWHATSAPP_API_PHONE_NUMBER
: WhatsApp phone number for the chatbotWHATSAPP_VERIFY_TOKEN
: WhatsApp webhook verification tokenOPENAI_API_KEY
: OpenAI API key for NLP tasksSPEECH_TO_TEXT_API_KEY
: API key for speech-to-text service
API Documentation
The API documentation is available at:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
- OpenAPI JSON:
http://localhost:8000/openapi.json
Monitoring
The application is set up with monitoring using Prometheus, Grafana, Loki, and Promtail:
- Prometheus:
http://localhost:9090
- Grafana:
http://localhost:3000
- Loki:
http://localhost:3100
Deployment
Docker Compose
docker-compose up -d
Kubernetes
Kubernetes manifests are provided in the k8s
directory.
kubectl apply -f k8s/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Description
Languages
Python
92.6%
Dockerfile
7.4%