OpenClaw-like Personal Assistant with Low Operational Cost
R2D2 is an autonomous personal assistant bot inspired by OpenClaw, designed to run on your own infrastructure with minimal operational costs. Unlike cloud-based AI assistants, R2D2 gives you full control over your data and can be deployed anywhere.
- Free LLM Options: Supports Google Gemini (15 RPM free tier)
- Affordable Alternatives: GLM 4.7 ($1/M tokens), Kimi k2.5 ($0.60/M tokens)
- Smart Routing: Automatically routes to cheaper models first
- Self-Hosted: No subscription fees, run on your own server
- Search Engines: Brave, Google, Yandex (Playwright-based)
- Travel: Google Flights & Hotels scraping
- Local Business: Google Maps & Reviews extraction
- Communication: WhatsApp CLI integration
- Self-Healing: Automatic retry with exponential backoff
- Self-Improvement: Learns from failures using ChromaDB
- External Validation: Fact-checks responses with web search
- Context Management: Smart conversation history with sliding window
- Tool-Based: Modular tool system with automatic registration
- Function Calling: Native LLM function calling support
- Multi-Provider: Seamless fallback between LLM providers
- Memory: Semantic search (ChromaDB) + SQL history
- Docker & Docker Compose
- At least 1 LLM API key (Gemini recommended for free tier)
- Telegram Bot Token (get from @BotFather)
- Clone the repository
git clone https://github.com/helioneto144/r2d2_bot.git
cd r2d2_bot- Configure environment
cp .env.template .env
nano .env # Add your API keys- Start with Docker
docker compose up -d- Check logs
docker logs telegram-bot --tail 50r2d2_bot/
βββ core/ # Core orchestration
β βββ orchestrator.py # Main coordinator
β βββ context_manager.py # Conversation context
β βββ config_loader.py # Settings management
βββ llm_router/ # LLM provider routing
β βββ router.py # Smart routing logic
β βββ providers/ # LLM implementations
β βββ gemini.py # Google Gemini
β βββ moonshot.py # Kimi (Moonshot)
β βββ zai.py # GLM (Z.AI)
βββ memory/ # Persistence layer
β βββ semantic_search.py # ChromaDB integration
β βββ conversation_store.py # SQLite history
βββ tools/ # Tool system
β βββ registry.py # Auto-discovery
β βββ built_in/ # Built-in tools
β βββ google_search.py
β βββ google_flights.py
β βββ google_hotels.py
β βββ ...
βββ self_heal/ # Autonomous features
β βββ auto_repair.py # Retry & fallback
β βββ self_improve.py # Learning from errors
β βββ external_validator.py # Fact-checking
βββ interfaces/ # User interfaces
βββ telegram_bot.py # Telegram integration
User Query β Router
β
βββββββ΄ββββββ
β GLM 4.7 β ($1.00/M) - Fastest, cheapest
β (Z.AI) β
βββββββ¬ββββββ
β (if fails)
βββββββ΄ββββββ
β Kimi k2.5 β ($0.60/M) - Balanced
β (Moonshot) β
βββββββ¬ββββββ
β (if fails)
βββββββ΄ββββββ
β Gemini 3 β (FREE 15 RPM) - Fallback
β Flash β
βββββββββββββ
| Tool | Technology | Cost |
|---|---|---|
brave_search |
Brave API | $5/month (1M queries) |
google_search |
Playwright scraping | Free |
yandex_search |
Playwright scraping | Free |
| Tool | Technology | Cost |
|---|---|---|
google_flights |
Playwright scraping | Free |
google_hotels |
Playwright scraping | Free |
| Tool | Technology | Cost |
|---|---|---|
google_maps_scraper |
Docker (gosom/google-maps-scraper) | Free |
google_reviews |
Playwright scraping | Free |
| Tool | Technology | Cost |
|---|---|---|
whatsapp_cli |
Go binary (vicentereig/whatsapp-cli) | Free |
/start - Start conversation
/help - Show help
/new - Clear context, start fresh
/tools - List available tools
/status - Show system status
"busque voos de GRU para GIG amanhΓ£"
β Uses google_flights tool with Playwright
"procure hotΓ©is em SΓ£o Paulo"
β Uses google_hotels tool
"o que vocΓͺ pode fazer?"
β Lists real capabilities (no hallucinated features)
| Feature | R2D2 | ChatGPT Plus | Claude Pro |
|---|---|---|---|
| Monthly Cost | ~$5-10 | $20 | $20 |
| Data Privacy | β Self-hosted | β Cloud | β Cloud |
| Custom Tools | β Easy to add | β Limited | β Limited |
| LLM Choice | β Multi-provider | β OpenAI only | β Anthropic only |
| Rate Limits | β Configurable | ||
| Open Source | β MIT License | β Proprietary | β Proprietary |
- Create a new tool file in
tools/built_in/:
from tools.base import BaseTool, ToolParam
class MyCustomTool(BaseTool):
name = "my_custom_tool"
description = "Does something useful"
parameters = [
ToolParam(
name="query",
type="string",
description="What to search for",
required=True
)
]
def execute(self, query: str) -> dict:
# Your logic here
return {
"success": True,
"data": {"result": "..."}
}- That's it! The tool will be auto-discovered and available to the LLM.
-
Never commit credentials
- Use
.envfile (already in.gitignore) - Use environment variables in production
- Use
-
API Key rotation
- Rotate keys periodically
- Use separate keys for dev/prod
-
Rate limiting
- Configure per-provider limits in
llm_router/rate_limiter.py - Prevents API abuse and cost overruns
- Configure per-provider limits in
-
Input validation
- All tools validate inputs
- SQL injection protection in conversation store
Gemini 3 Flash: FREE (15 RPM)
Hosting: $5/month (VPS)
Total: $5/month
GLM 4.7 (primary): ~$3/month (moderate use)
Gemini 3 Flash (fallback): FREE
Hosting: $10/month (better VPS)
Total: $13/month
GLM 4.7 + Kimi k2.5: ~$10/month
Brave Search API: $5/month
Hosting: $15/month (high-performance)
Total: $30/month
Still 33% cheaper than ChatGPT Plus!
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -r requirements.txt
# Install Playwright browsers
playwright install chromium
# Run tests
pytest- Web dashboard (FastAPI + React)
- Voice interface (Whisper integration)
- Mobile app (React Native)
- More LLM providers (OpenAI, Anthropic, Cohere)
- Tool marketplace (community-contributed tools)
- Multi-user support
- Conversation sharing & export
# Check if container is running
docker ps
# View logs
docker logs telegram-bot --tail 100
# Restart bot
docker compose restart telegram_bot# Reinstall Playwright inside container
docker exec telegram-bot playwright install chromium- Check API key validity
- Verify rate limits not exceeded
- Try fallback provider
MIT License - feel free to use for personal or commercial projects.
- Inspired by OpenClaw architecture
- Built with Playwright for web scraping
- Uses ChromaDB for semantic memory
- Telegram integration via python-telegram-bot
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Author: @helioneto144
Made with β€οΈ for the open source community
If you find this project useful, please consider giving it a βοΈ on GitHub!