# Marvin Telegram Bot Simple Telegram bot server that sends your Telegram messages and photos to OpenRouter and replies back. Recent conversation memory is stored persistently in SQLite. ## Setup 1. Copy the environment file: ```bash cp .env.example .env ``` 2. Edit `.env` and add: ```env TELEGRAM_BOT_TOKEN=... OPENROUTER_API_KEY=... SEARXNG_URL=http://192.168.0.225:8080 ``` Get your key from: ```text https://openrouter.ai/keys ``` 3. Define the bot personality in `personality.md`. Example: ```text You are Marvin, a funny, slightly sarcastic assistant. Keep replies short and playful. ``` Optional settings in `.env`: ```env OPENROUTER_MODEL=openai/gpt-5.4-mini PERSONALITY_FILE=personality.md MEMORY_DB=marvin.sqlite MAX_HISTORY_MESSAGES=20 ``` ## Memory Marvin stores chat messages and long-term memories in SQLite at `marvin.sqlite` by default. The AI receives: - the most recent `MAX_HISTORY_MESSAGES` chat messages - all long-term memories for the current Telegram chat Recent chat history commands: ```text /forget ``` Long-term memory commands: ```text /remember location = Zagreb /memories /forget_memory location /forget_memories ``` ## Web browsing Marvin will automatically search the web when a message looks like it needs current or live information, and it will return a short sourced summary directly. It uses your self-hosted SearXNG instance. It will also automatically generate an image when a message looks like an image-generation request. Use `/web` if you want to force a web search. Use `/image` if you want to force image generation. Example: ```text /web latest OpenRouter gpt-5.4-mini model ID ``` ## Images Send the bot a photo with an optional caption/question and it will analyze it using the configured OpenRouter model. Generate and send an image using Pollinations: ```text /image a sad robot drinking coffee in Zagreb, noir style ``` 4. Start the bot locally: ```bash npm start ``` Then open Telegram and message your bot. ## Production setup Recommended production setup: 1. Run Marvin as a **systemd** service 2. Keep using **polling** 3. Store config in `.env` 4. Run it as a dedicated unprivileged user 5. View logs with: ```bash journalctl -u marvin -f ``` See `deploy/README.md` and `deploy/marvin.service` for an example service configuration.