A Retrieval-Augmented Generation (RAG) bot that integrates with GPT-OSS via Hugging Face and provides access via Slack and WhatsApp. The runtime now starts cleanly on low-resource machines by using a lightweight hashing embedder unless sentence-transformers is installed.
- 🤖 RAG System: Upload documents and query them using natural language
- 💬 Slack Integration: Access the bot directly from Slack
- 📱 WhatsApp Integration: Query via WhatsApp using Twilio
- 🔍 Vector Search: Powered by ChromaDB for efficient document retrieval
- 🧠 AI Responses: Uses GPT-OSS via Hugging Face for intelligent answers
- 🍓 Low-Resource Startup: Runs without pulling GPU-only
torchdependencies by default - 🔐 Safer Defaults: Optional API key protection, Twilio signature validation, and SSRF protections for scrape/media URLs
chmod +x setup.sh
./setup.shEdit .env file with your credentials:
cp .env.example .env
nano .envRecommended configuration:
API_KEY: Protects REST endpoints such as/upload,/query,/stats, and/research/*HUGGINGFACE_API_TOKEN: Enables LLM-generated answers. Without it, the bot falls back to context excerpts.
Optional (for integrations):
- Slack:
SLACK_BOT_TOKEN,SLACK_SIGNING_SECRET - WhatsApp:
TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN,TWILIO_PHONE_NUMBER - Public webhook deployments:
PUBLIC_BASE_URL
./start.shBy default the app binds to 127.0.0.1. Set HOST=0.0.0.0 only when you intend to expose it behind a firewall or reverse proxy.
GET /- API informationGET /health- Health checkPOST /upload- Upload documents (PDF or text)POST /query- Query the RAG systemGET /stats- Get knowledge base statisticsPOST /slack/events- Slack webhookPOST /whatsapp/webhook- WhatsApp webhook
curl -X POST "http://localhost:8000/upload" \
-H "X-API-Key: your_api_key" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@document.pdf"curl -X POST "http://localhost:8000/query" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"question": "What is machine learning?"}'- Create a Slack app at https://api.slack.com/apps
- Add bot token scopes:
app_mentions:read,chat:write,files:read - Enable events:
app_mention,file_shared - Set event request URL:
https://your-domain.com/slack/events - Install app to workspace
- Create Twilio account at https://www.twilio.com
- Set up WhatsApp sandbox or get approved number
- Configure webhook URL:
https://your-domain.com/whatsapp/webhook - Keep
VALIDATE_TWILIO_SIGNATURES=truein production
- Raspberry Pi 4 (4GB+ RAM recommended)
- Python 3.10+
- 16GB+ SD card
- Use SSD instead of SD card for better I/O
- Increase swap space if needed
- Monitor temperature and use cooling
Create systemd service:
sudo nano /etc/systemd/system/ragbot.service[Unit]
Description=RAG Bot Service
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/ragbot
ExecStart=/home/pi/ragbot/.venv/bin/python main.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable ragbot.service
sudo systemctl start ragbot.service┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Slack/WhatsApp│ │ FastAPI App │ │ FlexaAI API │
│ │───▶│ │───▶│ │
│ User Input │ │ RAG System │ │ GPT-OSS-120B │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ ChromaDB │
│ Vector Store │
└─────────────────┘
- Large dependency installs: The default install no longer requires
sentence-transformers. If you want higher-quality embeddings, install it manually after the core app is working. - Slow Responses: Check network connection to Hugging Face
- ChromaDB Errors: Ensure write permissions to
chroma_dbanduser_datadirectories - Import Errors: Activate the virtual environment before running
- Webhook validation failures: Set
PUBLIC_BASE_URLso Twilio signature checks see the public URL Twilio calls
Check application logs:
tail -f logs/ragbot.logcurl http://localhost:8000/health- Fork the repository
- Create feature branch
- Make changes
- Test on Raspberry Pi
- Submit pull request
MIT License - see LICENSE file for details.