Skip to content

Manual Setup

This is the manual install procedure for technical users who’d rather not use the guided wizard. If you want the hand-held path, use the setup wizard instead as it creates .env, generates a safe CRYPTO_SECRET, configures PostgreSQL, and runs the install for you.

  • Bun
  • Node.js v20+ (used for MCP tooling)
  • PostgreSQL installed natively, or run in a Docker container (see step 2)

PostgreSQL schema, pgcrypto, seeds, and migrations initialize automatically on bot startup.

Terminal window
git clone https://github.com/Bredrumb/TomoriBot.git
cd TomoriBot
bun install --frozen-lockfile

Create your environment file from the example and fill in the required values:

Terminal window
cp .env.example .env

Required:

  • DISCORD_TOKEN — your Discord bot token (enable the GuildMembers, MessageContent, and GuildPresences privileged intents).
  • CRYPTO_SECRET — a 32-character encryption key (used to encrypt stored API keys).
  • PostgreSQL connection: POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB.

Optional tuning lives in .env.optional.example. Copy over any values you want to customize (limits, timeouts, feature toggles, sidecar URLs, etc.).

Terminal window
bun run dev

When you see TomoriBot up and running!, go to Discord and run /config setup in your server to add your AI provider key and initialize the bot. See the Quickstart for the in-Discord side.

Use bun run launch instead of bun run dev if you want optional sidecars (SearXNG, Crawl4AI, local TTS/STT) launched alongside the bot:

Terminal window
bun run launch --searxng --crawl4ai
bun run launch --help # see all flags

Optional extras (the manual “Full Install”)

Section titled “Optional extras (the manual “Full Install”)”

The setup wizard’s Full Install path layers four lightweight extras on top of the base install. None are required to run the bot, but each unlocks a feature. If you’re installing by hand, add whichever you want:

RAG (document uploads and cross-channel recall) stores embeddings in a vector column, which needs the pgvector extension. Install it for your PostgreSQL major version:

Terminal window
# Debian/Ubuntu, e.g. for PostgreSQL 16
sudo apt-get install -y postgresql-16-pgvector

Then enable it once on your database. Connect with psql using the POSTGRES_* values from your .env — it prompts for POSTGRES_PASSWORD:

Terminal window
# Native / host psql (substitute your own POSTGRES_USER and POSTGRES_DB):
psql -h localhost -p 5432 -U tomori -d tomodb
# Or, if the database runs in the Docker container from step 2:
docker exec -it tomori-db psql -U tomori -d tomori

Once connected, run:

CREATE EXTENSION vector;

Without pgvector the bot still runs but RAG features become completely unavailable. This extension is also required on the target database before restoring a backup; see Safe Migration for details.

pg_cron powers optional periodic database maintenance (cooldown/reminder-row cleanup). Docker Compose from this repo already configures it.

For a self-managed PostgreSQL, find your active config file:

SHOW config_file;

Enable the extension in postgresql.conf — append to shared_preload_libraries if it already lists other libraries:

shared_preload_libraries = 'pg_cron' # e.g. 'pg_stat_statements,pg_cron'
cron.database_name = 'your_dbname'

Restart PostgreSQL, then:

CREATE EXTENSION IF NOT EXISTS pg_cron;

Logit bias (emoji/word repetition penalties) needs local tokenizer assets:

Terminal window
bun run setup:tokenizers

Some families (e.g. Gemma) are gated and require a HuggingFace token after you accept their license:

Terminal window
# Windows (PowerShell)
$env:HF_TOKEN="hf_xxx"; bun run setup:tokenizers
# macOS/Linux
HF_TOKEN=hf_xxx bun run setup:tokenizers

Without this step logit bias is silently disabled and everything else works normally.

The bundled fetch_url tool falls back to the Python mcp-server-fetch package for browser-free page fetches. It needs Python 3:

Terminal window
pip install mcp-server-fetch
# Linux, if you hit "externally-managed-environment":
pip install --break-system-packages mcp-server-fetch
# ...or install it inside a virtualenv.

DuckDuckGo/Felo web_search is separate and ships with bun install --frozen-lockfile so no extra step needed.

Once you’re installed, the host-side scripts (bun run update, bun run backup, bun run restore-backup, bun run nuke-db, bun run rotate-keys, …) and the update and backup procedures all live on the Maintenance & Backups page. If you’re about to pull a new version, start with Safe Migration.