Logo Lanfrica

cleven12/personal-whatsapp-ai

Domaine:

natural language processing

Type de record:

software
Créateur:
cle
HĂ´te:
📱 Flask-based WhatsApp AI | Google Gemini (1.5/2.0) | Multi-key Fallback | Persistent JSON Memory | CGM Persona (Kiswahili-slang) # WhatsApp AI Bot **Personal AI assistant for WhatsApp, powered by Google Gemini** --- ## Overview A Flask-based WhatsApp chatbot that processes incoming messages via webhook and responds using Google Gemini AI. Built around a custom **CGM persona** — concise, playful, Kiswahili-flavored tone for personal use. --- ## Features | Feature | Description | |---|---| | **Multi-key fallback** | Rotates across multiple Gemini API keys automatically on quota exhaustion | | **Smart memory** | Stores last 4 conversation turns per user, persisted to JSON | | **Whapi integration** | Native support for Whapi.cloud webhook format | | **Auto model fallback** | Tries `gemini-2.0-flash` → `gemini-2.5-flash` → `gemini-1.5-flash` → `gemini-1.5-pro` | | **Session expiry** | Conversations auto-expire after 24 hours of inactivity | | **Full logging** | Console + file logging (`logs/webhook.log`) | --- ## Project Structure ``` . ├── src/ │ ├── app.py # Webhook endpoints │ ├── chatbot.py # Gemini integration + model fallback │ ├── conversation_memory.py # JSON storage + session management │ └── main.py # Entry point ├── data/conversations/ # Per-user conversation history ├── logs/webhook.log # Activity logs └── docs/ # Extended documentation ``` --- ## Quick Start ### Prerequisites - Python 3.11+ - Gemini API key — Get one free from Google AI Studio - *(Optional)* Whapi.cloud token for sending replies ### Setup ```bash git clone github.com cd 7ee149 pip install -r requirements.txt cp .env.example .env ``` Edit `.env`: ```env # Single key GEMINI_API_KEY=your_key_here # Multiple keys (recommended — each gets 1500 free requests/day) GEMINI_API_KEY=key1,key2,key3 # Optional: auto-reply via Whapi WHAPI_TOKEN=your_whapi_token WHAPI_BASE_URL=gate.whapi.cloud ``` ### Run ```bash python src/main.py ``` ### Test ```bash curl -X POST local …