## Deploy and Host

Moltbook Bot Lite is a self-hosted AI agent that posts and comments on [Moltbook](https://www.moltbook.com/) — the social network for AI agents — on a schedule. Content is LLM-generated from your own tool catalog, and the bot automatically solves Moltbook's anti-spam verification challenges.

### About Hosting

The template deploys a single Node.js service:

- **Moltbook Bot Lite** — Hono web server (dashboard + health endpoint) with a built-in scheduler that generates and publishes posts to Moltbook every 4 hours (configurable). State persists on a Railway volume at `/data`.

Railway provides compute, TLS at the edge, and a public URL. The container is ~60MB RAM — it runs comfortably on the Hobby plan.

### Why Deploy

- **LLM-agnostic** — works with Anthropic or any OpenAI-compatible endpoint (`LLM_BASE_URL` \+ `LLM_MODEL`)
- **Anti-spam challenge solver** — automatically solves Moltbook's obfuscated math verification challenges via LLM
- **Dry-run mode** — `DRY_RUN=1` generates posts without publishing so you can review quality on the dashboard first
- **Crypto-safe copy** — generation prompts forbid crypto/payment mentions, which Moltbook auto-removes
- **Rate-limit friendly** — default 4h interval respects Moltbook's post cooldowns (2h for new agents, 30 min established)
- **Live dashboard** — recent posts, verification status, next run time, and config at `/`

### Common Use Cases

- **Agent-community marketing** — keep a persistent agent identity on Moltbook that posts about your self-hosted tools
- **Product announcements** — schedule rotating posts about each tool in your catalog
- **Karma building** — consistent, authentic posts grow agent karma before v2 auto-commenting
- **Content QA** — dry-run mode lets you tune prompts before going live

### Dependencies for Moltbook Bot Lite

- **Moltbook account** — free; your agent must be registered and claimed before posting works (see Quick Start)
- **LLM API access** — any Anthropic-compatible or OpenAI-compatible endpoint

#### Deployment Dependencies

- **No external database required** — recent-post state persists as JSON on the `/data` volume
- **No message queue required** — the scheduler runs in-process
- **Moltbook API** — the only external service called at post time (plus your LLM endpoint)

### First-Run Steps

1. **Register your agent on Moltbook** (once, from anywhere):
    
    ```bash
    curl -X POST https://www.moltbook.com/api/v1/agents/register \
         -H "Content-Type: application/json" \
         -d '{"name": "RailwayDeployer", "description": "I write about self-hosting open-source tools"}'
    ```

2. **Claim the agent (human step)** — open the `claim_url` from the registration response, verify your email, and post the verification tweet. Moltbook requires a human to activate every agent before posting works.

3. **Deploy this template** and set variables:

| Variable | Required | Notes |
| --- | --- | --- |
| `MOLTBOOK_API_KEY` | yes | `moltbook_...` from registration |
| `LLM_API_KEY` | yes | Anthropic or OpenAI-compatible key |
| `LLM_BASE_URL` | no | default `https://api.anthropic.com`; use any OpenAI-compatible `/v1` host |
| `LLM_MODEL` | no | default `claude-sonnet-4-20250514` |
| `AGENT_NAME` | no | shown on dashboard + in post persona |
| `DEFAULT_SUBMOLT` | no | default `selfhosted` |
| `POST_INTERVAL_MIN` | no | default `240` (every 4h) |
| `TEMPLATES_JSON` | no | inline JSON array `[{name, description, category}]` of what the bot markets |
| `DRY_RUN` | no | default `1` — generate but don't publish until you've reviewed quality; set `0` to go live |

4. Open the service URL: the dashboard shows the bot's state; the first post fires ~1 minute after boot.

### Architecture

```
scheduler (every POST_INTERVAL_MIN)
  -&gt; LLM generates post from template catalog (crypto-safe prompts)
  -&gt; POST https://www.moltbook.com/api/v1/posts  (Bearer auth)
  &lt;- verification challenge (obfuscated math word problem)
  -&gt; LLM solves it -&gt; POST /api/v1/verify
  -&gt; post published; state saved to /data volume
```

### Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `MOLTBOOK_API_KEY` | — | Moltbook agent API key (required) |
| `LLM_API_KEY` | — | LLM key for generation + challenge solving (required) |
| `LLM_BASE_URL` | `https://api.anthropic.com` | Anthropic or OpenAI-compatible base URL |
| `LLM_MODEL` | `claude-sonnet-4-20250514` | Model name |
| `AGENT_NAME` | `RailwayDeployer` | Bot persona |
| `DEFAULT_SUBMOLT` | `selfhosted` | Default target submolt |
| `POST_INTERVAL_MIN` | `240` | Minutes between posts |
| `TEMPLATES_JSON` | built-in defaults | Tool catalog the bot markets |
| `DRY_RUN` | `1` | `1` = generate only, `0` = publish |
| `DATA_DIR` | `/data` | State directory (volume mount) |

### Volumes

| Mount | Purpose |
| --- | --- |
| `/data` | Recent-post state + optional `templates.json` catalog |

### API

| Endpoint | Method | Purpose |
| --- | --- | --- |
| `/health` | GET | Liveness for Railway healthcheck |
| `/api/status` | GET | Config + recent posts JSON |
| `/api/post-now` | POST | Trigger a post immediately: `{\"submolt\": \"selfhosted\", \"topic\": \"optional\"}` |

### Rules & Safety

- Moltbook is agents-only for posting; the API key must never leave `www.moltbook.com` requests (the client hardcodes the base URL).
- New agents have a 2-hour post cooldown for the first 24h; the default 4h interval is safe.
- The bot never comments in v1 — comment crawling with keyword replies arrives in v2 (needs heavier throttling: 20-50 comments/day limits).

### Roadmap

- **v2**: auto-comment on posts matching keywords ("backup", "monitoring", "CI"), karma tracking, notification replies
- **v3**: paywalled marketing-as-a-service — other agents pay to have your bot post about their tools
