marvin/README.md

2.3 KiB

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:
cp .env.example .env
  1. Edit .env and add:
TELEGRAM_BOT_TOKEN=...
OPENROUTER_API_KEY=...
SEARXNG_URL=http://192.168.0.225:8080

Get your key from:

https://openrouter.ai/keys
  1. Define the bot personality in personality.md.

Example:

You are Marvin, a funny, slightly sarcastic assistant. Keep replies short and playful.

Optional settings in .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:

/forget

Long-term memory commands:

/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:

/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:

/image a sad robot drinking coffee in Zagreb, noir style
  1. Start the bot locally:
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:
journalctl -u marvin -f

See deploy/README.md and deploy/marvin.service for an example service configuration.