safia CLI so you can manage the bot from anywhere in your terminal. No external cache server is required — SAFIA uses an in-memory cache backed by SQLite. Follow the steps below to go from zero to a live Telegram bot.
Prerequisites
Before you start, make sure you have:- A Telegram bot token — create one for free by messaging @BotFather on Telegram and running
/newbot - An LLM API key from Lunos, Groq, OpenAI, or any OpenAI-compatible provider
- A machine running Linux, macOS, or Windows with internet access
SAFIA does not require any external cache server. Chat history, rate-limit counters, and market data caches live in an in-memory cache that is persisted to SQLite (
CACHE_DB_PATH), so cached state survives bot restarts.Installation & Setup
1
Install SAFIA
Run the one-line installer for your operating system. It sets up all dependencies and registers the The installer automatically handles Git, uv, Python 3.12, and all Python dependencies. No Docker or external cache server required.Once complete, the
safia CLI command.- Linux / macOS
- Windows (PowerShell)
safia command is available in any new terminal session.2
Run the Setup Wizard
The interactive setup wizard creates your You will be asked for:
.env configuration file. It walks you through each required setting one prompt at a time.- Your Telegram bot token
- Your LLM provider (Lunos, Groq, OpenAI, or custom)
- Your LLM API key
- Database URL and persistent cache file path (defaults are pre-filled and work out of the box)
- Optional: a Groq API key for voice transcription (Whisper) if your LLM provider is not Groq
- Optional: a Firecrawl API key for web search and article fetching
3
Start the Bot
Launch the bot and admin dashboard as background daemons. On Linux this uses systemd, on macOS launchd, and on Windows Scheduled Tasks — so SAFIA restarts automatically after a reboot.Verify everything is running:To watch recent logs:
4
Send Your First Message on Telegram
Open Telegram and find the bot you created with BotFather. Send the
/start command to begin a new session, or send /help to see an overview of what SAFIA can do.From here, just chat naturally. For example:- “I spent 45000 on lunch today”
- “Show me my expenses this week”
- “What’s the current gold price?”
DAILY_MESSAGE_LIMIT variable in your .env.5
Access the Admin Dashboard (Optional)
The admin dashboard provides usage metrics, a user registry, and tools for uploading knowledge base documents.Open your browser and navigate to:
The dashboard requires HTTP Basic Auth. Set
ADMIN_USERNAME and ADMIN_PASSWORD in your .env file (or run safia config to edit them) before accessing the dashboard for the first time. If these are not set, the dashboard is accessible without a password — protect it before exposing the port.CLI Reference
Thesafia CLI manages every aspect of the bot’s lifecycle.
Next Steps
Configuration
Customise your LLM provider, database backend, rate limits, and more.
Admin Dashboard
Upload knowledge base documents and monitor user activity.