LeoBot is a FastAPI-based AI chatbot platform for intelligent, real-time conversations across multiple channels — including websites, Facebook Messenger, and Zalo Official Accounts. It integrates seamlessly with LEO CDP (Customer Data Platform) to serve both admins and end-users, delivering contextual, personalized answers powered by RAG (Retrieval-Augmented Generation) and advanced AI models like Google Gemini.
Try the chatbot in action: 👉 https://leobot.leocdp.com
LeoBot uses the Google Gemini API for natural, context-aware responses.
- Multi-channel support: Works with Facebook Messenger and Zalo OA.
- Gemini-powered intelligence: Uses Google Gemini API for high-quality understanding and generation.
- RAG-based reasoning: Combines knowledge retrieval with semantic memory.
- FastAPI backend: Lightweight, async, and production-ready.
- Redis rate limiting: Prevents spam and message floods.
- Custom personas: Supports user profiles, roles, and chat touchpoints.
- Prebuilt frontend demos: Jinja2 templates for quick UI testing and embedding.
(Coming soon — overview diagram and explanation of key modules.)
Handles message understanding, context retrieval, and Gemini-based response generation.
/fb-webhook
— Facebook Messenger/zalo-webhook
— Zalo Official Account
Uses a sorted-set time window to prevent excessive messaging per user.
git clone https://github.com/trieu/leo-bot
cd leo-bot
Make sure Docker CLI is installed:
docker --version
Then start the database:
./start_pgsql_pgvector.sh
This script:
- Launches a PostgreSQL 16 container (
pgsql16_vector
) - Mounts a persistent volume (
pgdata_vector
) - Enables pgvector and postgis extensions
- Creates the
customer360
database and schema - Handles collation version fixes automatically
To reset the database, run:
./start_pgsql_pgvector.sh --reset-db
You can connect manually:
psql -h localhost -U postgres -d customer360
pip install -r requirements.txt
Create a .env
file or edit main_config.py
:
LEOBOT_DEV_MODE=false
HOSTNAME=leobot.example.com
POSTGRES_URL=postgresql://postgres:password@localhost:5432/customer360
GOOGLE_APPLICATION_CREDENTIALS=your_credentials.json
GEMINI_API_KEY=your_gemini_api_key
REDIS_USER_SESSION_HOST=127.0.0.1
REDIS_USER_SESSION_PORT=6480
FB_VERIFY_TOKEN=
FB_PAGE_ACCESS_TOKEN=your_facebook_access_token
ZALO_OA_ACCESS_TOKEN=your_zalo_access_token
Gemini API setup:
- Get your API key at Google AI Studio
- For translation and related APIs, set up credentials in the Google Cloud Console
sudo apt install python-is-python3 python3.10-venv
python -m venv env
source env/bin/activate
pip install -r requirements.txt
After installation, refresh your shell.
Production mode:
./start_app.sh
Development mode:
./start_dev.sh
LeoBot will run at 0.0.0.0:8888
.
Open your browser and visit your configured HOSTNAME
to test.
Endpoint | Method | Description |
---|---|---|
/ask |
POST | Main chatbot endpoint |
/is-ready |
GET/POST | Gemini API readiness check |
/fb-webhook |
GET/POST | Facebook Messenger webhook |
/zalo-webhook |
POST | Zalo OA webhook |
/ping |
GET | Basic health check |
/get-visitor-info |
GET | Retrieve visitor info from Redis |
- Built on FastAPI with full async I/O.
- Message context stored in Redis.
- Embeddings via SentenceTransformer or Gemini Embeddings.
- Compatible with pgvector and other vector databases.
To extend LeoBot:
- Add webhook routes for new channels (Telegram, LINE, etc.)
- Create custom response modules in
rag_agent
- Integrate new LLM APIs or plugins
Run automated tests:
pytest
Or test manually:
curl -X POST http://localhost:8000/ask \
-H "Content-Type: application/json" \
-d '{"visitor_id": "demo", "question": "Hello!", "persona_id": "test"}'
Author: Trieu Nguyen YouTube: @bigdatavn Demo: https://leobot.leocdp.com
- Support Telegram, LINE, and WhatsApp
- Add knowledge-graph search (PostgreSQL + pgvector)
- Streaming chat via SSE/WebSocket
- AI analytics dashboard for admins
- Plugin SDK for external integrations
MIT License — free to use, modify, and share. Attribution is appreciated but not required.
LeoBot embodies the union of Dataism and AI pragmatism — an assistant that connects people and data through natural conversation. It’s not just automation; it’s augmentation — amplifying human understanding through intelligent dialogue.