An intelligent, RAG-powered WhatsApp AI assistant built with FastAPI and LLM APIs. Designed specifically to deliver context-aware, domain-specific insurance support for InsureLLM clients.
- Retrieval-Augmented Generation (RAG): Integrates vector stores to query InsureLLM policy documents and database records for grounded answers.
- WhatsApp Cloud API Integration: Handles real-time incoming messages, multi-turn user conversations, and status verification via webhooks.
- Low-Latency Async Backend: Built with FastAPI and Uvicorn for asynchronous message routing and fast response times.
- Domain Guardrails: Restricts model queries strictly to insurance coverage, contract terms, company policies, and support services.
| Component | Technology |
|---|---|
| Language | Python 3.11+ |
| Backend Framework | FastAPI, Uvicorn |
| Package Manager | uv / pip |
| Vector Database | ChromaDB (Vector_DB) |
| LLM & Embeddings | OpenAI API / NVIDIA NIM / Custom LLM |
| Messaging Platform | Meta WhatsApp Cloud API |
- Python 3.11 or higher
uvpackage manager (recommended) or standardpip- Meta Developer Account with WhatsApp Cloud API access
- API key for your preferred LLM provider
- Clone the repository:
git clone https://github.com/shaahmir/WhatsApp-AI-Assistant.git
cd WhatsApp-AI-Assistant
- Set up the virtual environment and install dependencies:
Using
uv:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync
Using pip:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
- Create a
.envfile from the template:
cp .env.example .env
- Add your credentials to
.env:
# WhatsApp Cloud API Configuration
PHONE_NUMBER_ID=YOUR_PHONE_NUMBER_ID
ACCESS_TOKEN=YOUR_ACCESS_TOKEN
VERIFY_TOKEN=YOUR_VERIFY_TOKEN
PHONE_NUMBER=YOUR_PHONE_NUMBER
WHATSAPP_BUSINESS_ACCOUNT_ID=YOUR_WA_BUSINESS_ACC
# LLM Provider Configurations
BASE_URL=LLM_PROVIDER_URL
API_KEY=YOUR_API_KEY
- Start the FastAPI server:
python -m uvicorn app:app --reload --port 8000
- Expose the local server for development:
ngrok http 8000
- Configure Webhook:
- Go to the Meta Developer Portal under WhatsApp Webhook Settings.
- Set Callback URL to
https://<your-ngrok-domain>/webhook. - Provide the
VERIFY_TOKENdefined in your.env. - Subscribe to the
messagesevent.
.
├── Vector_DB/ # Vector database index and persistent storage
├── .env.example # Environment variable template
├── ai.py # RAG pipeline logic and LLM prompt processing
├── app.py # FastAPI entry point and web server routes
├── config.py # App configuration, guardrails, and environment variables
├── webhook.py # Webhook authorization and event processing
└── whatsapp.py # Messaging client for sending WhatsApp payloads
This project is licensed under the MIT License.