Logo Lanfrica

kenbiz25/ComEMRSupport

Domaine:

healthcarenatural language processing

Type de record:

software
Créateur:
ken
Hôte:
AI Powered Whatsapp Chatbot for Clinicians and CHWs in Sierra Leone # ComEMR WhatsApp Support Bot AI Powered WhatsApp chatbot for **ComEMR Support** built using **FastAPI**, **WhatsApp Cloud API**, and **OpenAI**. It uses Retrieval-Augmented Generation (RAG) for context-aware answers and sanitizes responses to avoid leaking internal KB details. --- ## ✅ Features - Responds to user queries via WhatsApp - Uses RAG for intelligent, context-based answers - Sanitizes responses (no KB paths or internal details) - Supports sending **text**, **media**, and **templates** - Configurable guardrails for security and compliance --- ## ✅ Project Structure ``` apps/ whatsapp_gateway/ # WhatsApp routes and send logic config/ # Settings and rate limit configs core/ # Indexing, KB, FAISS store jobs/ # Background tasks (e.g., reindex KB) rag/ # Composer and retrieval logic tests/ # Unit tests prompts/ # System prompt templates app.py # FastAPI entry point requirements.txt # Dependencies ``` --- ## ✅ Setup Instructions ### 1. Clone the Repo ```bash git clone github.com cd ComEMRSupport ``` ### 2. Create Virtual Environment ```bash python -m venv venv # Activate: # Windows: venv\Scripts\activate # Linux/Mac: source venv/bin/activate ``` ### 3. Install Dependencies ```bash pip install -r requirements.txt ``` ### 4. Configure Environment Variables Create a `.env` file in the root: ``` WHATSAPP_PHONE_ID= META_WHATSAPP_TOKEN= META_VERIFY_TOKEN=ComEMR1234 OPENAI_API_KEY= KB_DIR=KB TOP_K=3 ANSWER_CONFIDENCE_THRESHOLD=0.45 ``` --- ## ✅ Running the Bot ### Start FastAPI App ```bash uvicorn app:app --host 0.0.0.0 --port 8000 --reload ``` ### Expose via Ngrok ```bash ngrok http 8000 ``` Copy the **Forwarding URL** and set it as your webhook in **Meta Developer Dashboard**. --- ## ✅ WhatsApp Cloud API Integration ### Sending Text Messages Example in `apps/whatsapp_gateway/send.py`: ```python def send_whatsapp_tex …