safia CLI so you can manage the bot from anywhere in your terminal. 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
Installation & Setup
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, Redis, and all Python dependencies. No Docker required.Once complete, the
safia CLI command.- Linux / macOS
- Windows (PowerShell)
safia command is available in any new terminal session.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 and Redis URLs (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
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:
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 /bantuan 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.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.
| Command | Description |
|---|---|
safia setup | Run the interactive setup wizard |
safia config | View and edit configuration interactively |
safia start | Start bot and admin dashboard daemons |
safia stop | Stop both daemons |
safia restart | Restart both daemons |
safia status | Show current daemon status |
safia logs [N] | Show recent logs (default: last 30 lines) |
safia update | Pull latest changes, update deps, and restart |
safia test | Run the test suite |
safia uninstall | Remove SAFIA completely |
Next Steps
Configuration
Customise your LLM provider, database backend, rate limits, and more.
Admin Dashboard
Upload knowledge base documents and monitor user activity.