answerLoopsanswerLoopsDocs

Self-host quickstart

Run answerLoops on your own infrastructure with one command. The installer starts the published Docker image with a bundled Postgres, or uses your own database.

Use this guide to operate answerLoops on infrastructure you manage. You will configure the application, database, authentication, model services, and channel connections. External model providers and connected platforms still process relevant content; review those services separately from the application’s hosting location.

This is the fast path: one machine, Docker, and one command. The self-hosting guide covers everything after it, including every environment variable, channel setup, production deployment, and upgrades.

If you'd rather skip all of this, the cloud quickstart gets you the same product with none of the infrastructure.

Using Claude Code? Install the answerloops-setup skill and have your agent run this guide for you. It runs the same installer, collects the values it asks for, and confirms the instance is healthy before handing back.

Before you start

You need:

  • Git, to clone the repository.
  • Docker with Compose v2. Docker Desktop includes Compose; on Linux, install the Compose plugin.
  • Node.js 18 or newer, to run the installer with npx.
  • A Google OAuth client or a GitHub OAuth App, because that is how you sign in. Follow OAuth setup.
  • An AI provider key. An OpenAI key is the simplest start. See Prerequisites.

You do not need your own Postgres. If you don't give the installer one, it runs a database for you alongside the app.

The flow at a glance

Here is the whole flow in one picture; each step is spelled out below.

Install flow: the installer checks git and Docker, clones the repository, writes .env with generated secrets, then either uses your DATABASE_URL or sets up a bundled Postgres. It starts the stack with Docker Compose and waits for the health check before you sign in.

1. Run the installer

npx @answerloops/agent-sdk setup

Run it from the folder you want the install in. It clones into ./answerLoops, or uses the checkout you are already in. Step by step, it:

Checks prerequisites. It confirms git and Docker with Compose v2 are installed, and stops with a link for anything missing.

Gets the code. It clones the repository unless the current folder (or the --dir folder) is already a checkout. Only the compose files and your .env are used; the app itself runs from the published image, so nothing is built.

Writes .env with generated secrets. AUTH_SECRET and ENCRYPTION_KEY are generated with real randomness and written to .env. They are never printed.

Chooses the database. If DATABASE_URL is set, in .env or exported in your shell, it uses that database. If not, it sets up a bundled Postgres: it generates POSTGRES_PASSWORD, points DATABASE_URL at the bundled database, and records the choice as ANSWERLOOPS_BUNDLED_DB=true. It tells you which one it picked.

Checks the values only you can provide. If AUTH_URL is missing, or neither the Google nor the GitHub sign-in pair is complete, it lists them and stops. See step 2.

Starts the stack and waits for it. It runs Docker Compose with the published image (plus the bundled database, if it chose one), then polls /api/health until the app answers. The first run takes as long as the image download.

OptionWhat it does
--dir <path>Clone into this folder instead of ./answerLoops
--external-dbNever bundle a database. Without DATABASE_URL, stop and say what to add
--with-skillsAlso install the Claude Code setup and operate skills into ./.claude/skills/

2. Add the values it asks for

On the first run, the installer stops and lists what it can't make up for you. Add them to .env in the cloned folder (or export them in your shell; the installer copies them into .env), then run the same command again from that folder:

# The address you will open answerLoops at
AUTH_URL=http://localhost:3000

# Sign-in (Google or GitHub; the sign-in page shows no button without credentials)
AUTH_GOOGLE_ID=<your-google-oauth-client-id>
AUTH_GOOGLE_SECRET=<your-google-oauth-client-secret>
# Or GitHub sign-in:
# AUTH_GITHUB_ID=<your-github-oauth-client-id>
# AUTH_GITHUB_SECRET=<your-github-oauth-client-secret>

# AI (required for deflection and KB search; or save a key per workspace in Settings)
OPENAI_API_KEY=<your-openai-api-key>

Register {AUTH_URL}/api/auth/callback/google as the redirect URI on your Google client, or {AUTH_URL}/api/auth/callback/github as the callback URL on your GitHub OAuth App. For a local install those are http://localhost:3000/api/auth/callback/google and http://localhost:3000/api/auth/callback/github. The installer keeps everything it already wrote, including your generated secrets and database password, and only reports what is still missing.

This project uses Auth.js v5. The env vars are AUTH_URL and AUTH_SECRET — not NEXTAUTH_URL / NEXTAUTH_SECRET.

The full environment variables reference lists every option.

Bundled database or your own

This is what you get when DATABASE_URL is not set. The installer adds a postgres service running pgvector/pgvector:pg16, which includes the pgvector extension answerLoops needs. Its data lives in the answerloops_pgdata Docker volume, so it survives restarts and upgrades.

  • The database publishes no port on your machine. The app and bot reach it as postgres inside Docker; use docker compose exec to look inside (see step 4).
  • POSTGRES_PASSWORD in .env is the database password. The volume was created with it, so keep it and never change it.
  • Every later run reads ANSWERLOOPS_BUNDLED_DB=true from .env and keeps the same database, so re-running the installer is safe.
  • Backups are yours to take. See Upgrading for the pg_dump command.

Never run docker compose down -v — this deletes your database volume and all data. Use docker compose down (no -v) to stop without data loss.

3. Create your account

When the installer prints that your instance is live, open your AUTH_URL (for example http://localhost:3000) and sign in with Google or GitHub. On first login you'll see the onboarding wizard:

  1. Connect your community — Discord 1-click invite, Slack token, or skip
  2. Seed your knowledge base — drag-drop docs files or paste a URL
  3. Configure AI — verify your API key and pick a model
  4. Go live — checklist summary with links to Tickets and KB

4. Verify it works

Run these from the cloned folder:

# Health check
curl http://localhost:3000/api/health
# → {"ok":true}

Database migrations run automatically every time the app starts. To confirm the tables were created:

docker compose -f docker-compose.ghcr.yml -f docker-compose.ghcr.postgres.yml \
  exec postgres psql -U community -d community -c "\dt"

Run, stop, and upgrade

The installer prints the compose command for your install when it finishes. With a bundled database, every compose command needs both files, or the database is left out:

# Bundled Postgres
docker compose -f docker-compose.ghcr.yml -f docker-compose.ghcr.postgres.yml logs app -f
docker compose -f docker-compose.ghcr.yml -f docker-compose.ghcr.postgres.yml down

# Your own Postgres
docker compose -f docker-compose.ghcr.yml logs app -f
docker compose -f docker-compose.ghcr.yml down

To upgrade, back up your database and run npx @answerloops/agent-sdk setup again from the cloned folder. It pulls the newest image and keeps the same database choice. Upgrading has the full steps, version pinning, and rollback.

Manual setup (build from source)

Prefer to run Compose yourself? You can skip the installer, configure .env by hand, and start the development stack, which builds from your checkout and includes its own Postgres. Docker setup covers the published image and the production build as well.

Clone the repo

git clone https://github.com/answerLoops/answerLoops.git
cd answerLoops

Configure environment

cp .env.example .env

Edit .env with at minimum:

# Required
DATABASE_URL=postgresql://community:community@postgres:5432/community
AUTH_URL=http://localhost:3000
AUTH_SECRET=<run: openssl rand -hex 32>
ENCRYPTION_KEY=<run: openssl rand -hex 32>

# Sign-in (Google or GitHub; the sign-in page shows no button without credentials)
AUTH_GOOGLE_ID=<your-google-oauth-client-id>
AUTH_GOOGLE_SECRET=<your-google-oauth-client-secret>
# Or GitHub sign-in:
# AUTH_GITHUB_ID=<your-github-oauth-client-id>
# AUTH_GITHUB_SECRET=<your-github-oauth-client-secret>

# AI (required for deflection and KB search)
OPENAI_API_KEY=<your-openai-api-key>

To generate the two secrets, see Generating secrets.

Start with Docker

Once your .env has real values (not the ones above), this one command does the rest:

docker compose up --build

This starts:

  • app on http://localhost:3000
  • bot, which runs the background jobs (knowledge-base syncs, draft retries, Slack polling, lead emails) and connects to Discord once a Discord connection is saved
  • postgres on localhost:5432 (data persisted in a named volume)

Drizzle migrations run automatically on first start — no manual migration step. The default compose file sets the database address itself, so the app and bot use this Postgres whatever DATABASE_URL says.

This is the development stack: it mounts the source and runs pnpm dev, which is the quickest way to try changes to answerLoops. For a deployment that stays up, use the installer above or follow the production guide.

Then create your account as above. To check the tables, run docker compose exec postgres psql -U community -d community -c "\dt".

Next steps

On this page