* feat: add Railway deployment support with agent auto-discovery - Add railway.toml for build/deploy config with health checks - Skip config file requirement when RAILWAY_ENVIRONMENT detected - Auto-discover existing agent by name on container deploys - Add findAgentByName() API function for agent lookup - Add setAgentId() method to LettaBot class - Add comprehensive Railway deployment docs One-click deploy flow: 1. Set LETTA_API_KEY + channel tokens 2. LettaBot finds existing agent by AGENT_NAME (default: "LettaBot") 3. If not found, creates on first message 4. Subsequent deploys auto-reconnect to same agent Written by Cameron ◯ Letta Code "The best way to predict the future is to deploy it." - Railway, probably * fix: specify Node 22 for Railway deployment * fix: fail fast if LETTA_API_KEY is missing * fix: don't await Telegram bot.start() - it never resolves * fix: extract message from send_message tool call * Revert "fix: extract message from send_message tool call" This reverts commit 370306e49de3728434352d2df1b78c744e888833. * fix: clear LETTA_AGENT_ID env var when agent doesn't exist * docs: add Railway deploy button to README and docs * fix: .nvmrc newline and correct MODEL default in docs
2.9 KiB
2.9 KiB
Railway Deployment
Deploy LettaBot to Railway for always-on hosting.
One-Click Deploy
- Fork this repository
- Connect to Railway
- Set environment variables (see below)
- Deploy!
No local setup required. LettaBot automatically finds or creates your agent by name.
Environment Variables
Required
| Variable | Description |
|---|---|
LETTA_API_KEY |
Your Letta Cloud API key (get one here) |
Channel Configuration (at least one required)
Telegram:
TELEGRAM_BOT_TOKEN=your-bot-token
TELEGRAM_DM_POLICY=pairing
Discord:
DISCORD_BOT_TOKEN=your-bot-token
DISCORD_DM_POLICY=pairing
Slack:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
Optional
| Variable | Default | Description |
|---|---|---|
AGENT_NAME |
LettaBot |
Agent name (used to find/create agent) |
MODEL |
zai/glm-4.7 |
Model for new agents (ignored for existing agents) |
LETTA_AGENT_ID |
- | Override auto-discovery with specific agent ID |
CRON_ENABLED |
false |
Enable cron jobs |
HEARTBEAT_INTERVAL_MIN |
- | Enable heartbeats (minutes) |
HEARTBEAT_TARGET |
- | Target chat (e.g., telegram:123456) |
OPENAI_API_KEY |
- | For voice message transcription |
How It Works
Agent Discovery
On startup, LettaBot:
- Checks for
LETTA_AGENT_IDenv var - uses if set - Otherwise, searches Letta Cloud for an agent named
AGENT_NAME(default: "LettaBot") - If found, uses the existing agent (preserves memory!)
- If not found, creates a new agent on first message
This means your agent persists across deploys without any manual ID copying.
Build & Deploy
Railway automatically:
- Detects Node.js and installs dependencies
- Runs
npm run buildto compile TypeScript - Runs
npm startto start the server - Sets the
PORTenvironment variable - Monitors
/healthendpoint
Channel Limitations
| Channel | Railway Support | Notes |
|---|---|---|
| Telegram | Yes | Full support |
| Discord | Yes | Full support |
| Slack | Yes | Full support |
| No | Requires local QR pairing | |
| Signal | No | Requires local device registration |
Troubleshooting
"No channels configured"
Set at least one channel token (TELEGRAM_BOT_TOKEN, DISCORD_BOT_TOKEN, or SLACK tokens).
Agent not found / wrong agent
- Check
AGENT_NAMEmatches your intended agent - Or set
LETTA_AGENT_IDexplicitly to use a specific agent - Multiple agents with the same name? The most recently created one is used
Health check failing
Check Railway logs for startup errors. Common issues:
- Missing
LETTA_API_KEY - Invalid channel tokens
Deploy Button
Or add to your README:
[](https://railway.com/deploy/lettabot)