An AI-powered multilingual healthcare assistance platform that provides general health information through WhatsApp using medical-focused Large Language Models, Retrieval-Augmented Generation (RAG), voice processing, multilingual NLP, and automated health outbreak monitoring.
-
💬 WhatsApp Health Chatbot using Twilio
-
🤖 Medical-focused LLM using NVIDIA NIM / Palmyra-Med-70B
-
📚 Retrieval-Augmented Generation (RAG) for grounded responses
-
🔎 FAISS vector search for semantic document retrieval
-
🌍 Multilingual support
- English
- Tamil
- Hindi
-
🎙️ Voice message processing
- Whisper speech-to-text
- gTTS text-to-speech
-
🏥 External health information integration
- WHO
- MedlinePlus
- disease.sh
-
🚨 Health outbreak monitoring
- RSS-based monitoring
- automated alert processing
- subscriber notifications
flowchart LR
A["WhatsApp User"] --> B["Twilio WhatsApp API"]
B --> C["Flask Webhook"]
C --> D{"Request Validation"}
D -->|Valid| E["Language Detection"]
D -->|Invalid| X["Reject Request"]
E --> F{"Message Type"}
F -->|Text| G["User Query"]
F -->|Voice| H["Whisper Speech-to-Text"]
H --> G
G --> I["RAG Pipeline"]
I --> J["Sentence Transformer"]
J --> K["FAISS Semantic Search"]
K --> L["Relevant Health Context"]
L --> M["Medical LLM<br/>NVIDIA NIM / Palmyra-Med-70B"]
G --> M
M --> N["Medical Safety Layer"]
N --> O{"Response Type"}
O -->|Text| P["Text Response"]
O -->|Voice| Q["gTTS Text-to-Speech"]
P --> R["Twilio WhatsApp API"]
Q --> R
R --> S["WhatsApp User"]
T["WHO / MedlinePlus / disease.sh"] --> I
U["Health RSS Feeds"] --> V["Outbreak Monitoring"]
W["APScheduler"] --> V
V --> X1["Alert Processing"]
X1 --> Y["Admin Review"]
Y --> Z["Subscriber Management"]
Z --> AA["WhatsApp Alert Broadcast"]
AA --> B
AB["Admin API"] --> AC["Admin Authentication"]
AC --> Y
WhatsApp Voice Message
│
▼
Twilio
│
▼
Media Download
│
▼
Whisper
│
▼
Speech-to-Text
│
▼
Language Detection
│
▼
RAG + LLM
│
▼
Response
│
▼
gTTS
│
▼
Audio Response
│
▼
WhatsApp
flowchart LR
A["WHO / Health RSS Feeds"] --> B["Feed Monitoring"]
B --> C["Article Processing"]
C --> D["Alert Detection"]
D --> E["Admin Approval"]
E --> F["Subscriber Management"]
F --> G["WhatsApp Notifications"]
G --> H["Subscribers"]
| Component | Technology |
|---|---|
| Backend | Python |
| Web Framework | Flask |
| Messaging | WhatsApp + Twilio |
| LLM | NVIDIA NIM / Palmyra-Med-70B |
| AI API | OpenAI-compatible API |
| RAG | Retrieval-Augmented Generation |
| Vector Database | FAISS |
| Embeddings | Sentence Transformers |
| Speech-to-Text | OpenAI Whisper |
| Text-to-Speech | Google Text-to-Speech (gTTS) |
| Language Detection | langdetect + ensemble detection |
| PDF Processing | pypdf |
| Feed Monitoring | feedparser |
| Scheduling | APScheduler |
| HTTP Requests | Requests |
| Tunneling | pyngrok |
| Storage | JSON |
| Testing | Python unittest |
Health_Chatbot/
│
├── app.py
├── config.py
├── requirements.txt
├── README.md
├── .env.example
├── .gitignore
│
├── bot/
│ ├── __init__.py
│ ├── external_apis.py
│ ├── feeds.py
│ ├── language.py
│ ├── llm.py
│ ├── rag.py
│ ├── storage.py
│ └── voice.py
│
├── routes/
│ ├── __init__.py
│ ├── admin.py
│ └── webhook.py
│
└── tests/
├── __init__.py
└── test_healthbot.py
Runtime directories such as .venv/, data/, __pycache__/, temporary files, generated audio, and local runtime state are excluded from version control through .gitignore.
- Python 3.10+
- Twilio account with WhatsApp access
- NVIDIA API key
- Internet connection for external APIs and model services
- FFmpeg for audio processing where required by the voice pipeline
git clone https://github.com/MathuBharathi/Health_Chatbot.git
cd Health_ChatbotWindows:
python -m venv .venv
.venv\Scripts\Activate.ps1Linux/macOS:
python3 -m venv .venv
source .venv/bin/activatepython -m pip install --upgrade pip
pip install -r requirements.txtCreate a .env file based on .env.example.
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_WHATSAPP_NUMBER=your_whatsapp_number
NVIDIA_API_KEY=your_nvidia_api_key
ADMIN_TOKEN=your_secure_admin_token
FLASK_SECRET_KEY=your_random_secret_key
FLASK_DEBUG=false
SKIP_TWILIO_VALIDATION=falseNever commit .env to GitHub.
Only .env.example containing placeholder values should be committed.
Generate a strong random value for:
FLASK_SECRET_KEY
ADMIN_TOKEN
-
Create and configure a Twilio account.
-
Enable WhatsApp messaging.
-
Obtain:
- Account SID
- Auth Token
- WhatsApp sender number
-
Configure the WhatsApp webhook to point to the Flask application.
For local development, a tunneling service such as ngrok can expose the local Flask server.
Example:
https://your-ngrok-url/webhook
Production mode uses Twilio request signature validation.
The recommended configuration is:
SKIP_TWILIO_VALIDATION=falseDevelopment bypass can be explicitly enabled when necessary:
SKIP_TWILIO_VALIDATION=trueDo not use validation bypass in a production deployment.
HealthBot uses a medical-focused LLM through an NVIDIA NIM-compatible API.
Configure the API key through:
NVIDIA_API_KEY=your_nvidia_api_keyThe application should never contain the actual API key in source code.
The LLM is used together with retrieved contextual information when available.
HealthBot uses RAG to improve the grounding of responses.
The general pipeline is:
Medical Documents
│
▼
PDF/Text
│
▼
Text Chunks
│
▼
Sentence Transformer
│
▼
Embeddings
│
▼
FAISS
│
▼
Semantic Retrieval
│
▼
Relevant Context
│
▼
Medical LLM
│
▼
Grounded Response
The application includes defensive handling for situations such as:
- missing indexes
- corrupted indexes
- missing metadata
- empty documents
- empty retrieval results
- unavailable embedding models
HealthBot supports:
- 🇬🇧 English
- 🇮🇳 Tamil
- 🇮🇳 Hindi
Language detection is performed before processing the user's request.
The detected language is used to provide an appropriate response.
The application is designed to preserve Unicode text throughout the processing pipeline.
HealthBot supports voice messages through the WhatsApp integration.
OpenAI Whisper is used to convert incoming audio into text.
Voice Message
↓
Audio Download
↓
Whisper
↓
Transcribed Text
Generated responses can be converted back into speech using gTTS.
AI Response
↓
gTTS
↓
Audio File
↓
WhatsApp
Temporary audio files are cleaned up after processing.
HealthBot can integrate external health information sources including:
- WHO
- MedlinePlus
- disease.sh
External services are handled with timeout and error-handling mechanisms so that a temporary API failure does not unnecessarily crash the application.
HealthBot includes an automated health-outbreak monitoring component.
The system can process health-related RSS feeds and identify relevant updates.
The general workflow is:
Health RSS Feeds
↓
Feed Fetching
↓
Article Parsing
↓
Alert Processing
↓
Admin Review
↓
Subscriber Notification
APScheduler is used for background scheduled operations.
After configuring .env:
python app.pyThe Flask application will start according to the configured environment.
For local WhatsApp development, expose the application through a secure HTTPS tunnel and configure the corresponding Twilio webhook.
Recommended development workflow:
git pullCreate or activate the virtual environment:
python -m venv .venvInstall dependencies:
pip install -r requirements.txtRun tests:
python -m unittest discover -s tests -p "test_*.py" -vCheck syntax:
python -m compileall .HealthBot demonstrates how multiple AI and software engineering technologies can be combined into a single conversational healthcare platform:
- Generative AI
- Medical language models
- Retrieval-Augmented Generation
- Semantic search
- Voice AI
- Multilingual NLP
- WhatsApp automation
- Health information APIs
- Real-time health monitoring
- Automated notifications
- Secure backend development
This project currently does not include an open-source license.
Until a license is added, the source code should not be assumed to be freely reusable, modified, or redistributed.
MathuBharathi
GitHub: https://github.com/MathuBharathi
