What is .env?
The.env file stores configuration values that change between environments (development, staging, production) or contain sensitive information like API keys and secrets.
Why use .env files? - Keep secrets out of code (never commit them to git) - Different values
for different environments - Easy to change without modifying code - Follows the 12-factor
app methodology
How It Works
- You create a
.envfile in the project root - The app loads these values at startup
- Code accesses them via
process.env.VARIABLE_NAME
Files in This Project
| File | Purpose | Committed to Git? |
|---|---|---|
.env.example | Template with all variables | Yes |
.env | Your actual configuration | No (gitignored) |
.env.local | Local overrides (optional) | No |
.env.test | Test environment (optional) | No |
Quick Setup
Required Variables
These must be set for the application to start.Database Connection
- Using Docker (Recommended)
- External Database
If you’re using These match the credentials in
make db-up or docker-compose, use these defaults:docker-compose.yml.JWT Secret
The JWT secret is used to sign authentication tokens. It must be:- At least 32 characters long
- Random and unpredictable
- Different for each environment
Generate a secure secret
Run this command in your terminal:This outputs a 64-character hex string like:
LLM Configuration
Hitler uses LLMs for natural language task parsing. You need at least one provider configured.Option 1: Anthropic (Claude) - Recommended
Create an Anthropic account
Go to console.anthropic.com and sign up.
Get your API key
- Navigate to API Keys in the dashboard 2. Click Create Key 3. Copy the key (starts
with
sk-ant-)
| Model | Speed | Cost | Best For |
|---|---|---|---|
claude-3-haiku-20240307 | Fastest | Lowest | Development, simple tasks |
claude-3-sonnet-20240229 | Medium | Medium | Production |
claude-3-opus-20240229 | Slowest | Highest | Complex reasoning |
Option 2: OpenAI (GPT)
Create an OpenAI account
Go to platform.openai.com and sign up.
Get your API key
- Go to API Keys section 2. Click Create new secret key 3. Copy the key (starts with
sk-)
| Model | Speed | Cost | Best For |
|---|---|---|---|
gpt-4o-mini | Fast | Low | Development, simple tasks |
gpt-4o | Medium | Medium | Production |
gpt-4-turbo | Slower | Higher | Complex tasks |
LLM Settings
No LLM key? The app will use mock responses in development. Task parsing will return
placeholder data, which is fine for UI development but not realistic testing.
Slack Integration
The Hitler Slack bot uses Socket Mode, which means it connects to Slack via WebSocket instead of HTTP webhooks. This is simpler for local development since you don’t need ngrok or a public URL.Create a Slack App
Go to Slack API
Visit api.slack.com/apps and click Create New App.
Choose creation method
Select From scratch, enter a name (e.g., “Hitler Dev”), and select your workspace.
Enable Socket Mode
Configure OAuth Scopes
In your Slack App settings, go to OAuth & Permissions: Bot Token Scopes (required):Install to Workspace and Get Bot Token
Install the App
- Go to Install App in the left sidebar 2. Click Install to Workspace 3. Authorize the requested permissions
Configure Event Subscriptions
Subscribe to Bot Events
Under Subscribe to bot events, add: -
app_home_opened - App home tab views - app_mention- @mentions in channels -
message.im- Direct messages
With Socket Mode, you don’t need to set a Request URL - events are delivered over the WebSocket
connection.
Create Slash Command (Optional)
Add All Credentials to .env
Run the Bot
Now you can DM your bot in Slack or @mention it in channels!
Email Configuration (Optional)
For sending email notifications (password resets, alerts, etc.).Option 1: Resend (Recommended)
Create a Resend account
Go to resend.com and sign up.
Option 2: SMTP
For using any SMTP server (Gmail, SendGrid, Mailgun, etc.):Secrets Storage (Production)
In production, platform OAuth tokens (Slack) are stored encrypted in Cloudflare KV.Set Up Cloudflare KV
Create a Cloudflare account
Go to cloudflare.com and sign up.
Create a KV namespace
- Go to Workers & Pages → KV
- Click Create a namespace
- Name it (e.g., “hitler-secrets-prod”)
- Copy the Namespace ID
Create an API token
- Go to My Profile → API Tokens
- Click Create Token
- Use Edit Cloudflare Workers template
- Copy the token
Cloudflare KV is only needed in production. In development, secrets are stored in memory (which is
fine for local testing).
Context Memory (Optional)
The context memory system enables passive intelligence by listening to Slack channel messages, extracting facts, and building organizational memory.URL Fetching (Jina Reader)
@extractus/article-extractor if Jina is unavailable.
Web Search (Tavily)
search_web LLM tool to search the web for current information.
Tuning Parameters
The context memory system also uses
OPENAI_API_KEY (for text-embedding-3-small embeddings) and ANTHROPIC_API_KEY (for Claude Haiku fact extraction). These are already configured as part of the LLM setup above.Rate Limiting
Configure API rate limits to prevent abuse.| Environment | Window | Max Requests | Result |
|---|---|---|---|
| Development | 60000 | 1000 | 1000 req/min (relaxed) |
| Production | 60000 | 100 | 100 req/min (standard) |
| Strict | 60000 | 30 | 30 req/min (for sensitive endpoints) |
Task Configuration
Logging
| Level | When to Use |
|---|---|
debug | Development - verbose output |
info | Production - normal operations |
warn | Production - only warnings and errors |
error | Production - only errors |
Complete .env Template
Here’s a complete template with all variables:Security Best Practices
Never commit .env
The
.gitignore already excludes .env files. Never override this.Use different secrets per environment
Generate unique JWT secrets, encryption keys for dev/staging/prod.
Rotate secrets regularly
Change API keys and secrets periodically, especially after team changes.
Use a secrets manager in production
Consider tools like HashiCorp Vault, AWS Secrets Manager, or Doppler.
Troubleshooting
App won't start - missing DATABASE_URL
App won't start - missing DATABASE_URL
Ensure you’ve copied
.env.example to .env and the database is running:JWT_SECRET must be at least 32 characters
JWT_SECRET must be at least 32 characters
Generate a proper secret:
bash node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" LLM returns mock responses
LLM returns mock responses
You need to set either
ANTHROPIC_API_KEY or OPENAI_API_KEY for real LLM responses.Slack bot won't start
Slack bot won't start
“You must provide an appToken” error:
- Set
SLACK_APP_TOKENin your.env(starts withxapp-) - Generate one in Slack App → Socket Mode → App-Level Tokens
- Verify
SLACK_BOT_TOKENis correct (starts withxoxb-) - Re-install the app to your workspace if needed
Slack bot not receiving messages
Slack bot not receiving messages
- Ensure Socket Mode is enabled in your Slack App settings 2. Verify Event Subscriptions has
message.imandapp_mentionsubscribed 3. For channel messages, the bot must be invited to the channel 4. Check thatSLACK_SIGNING_SECRETmatches your app
Environment variable not loading
Environment variable not loading
- Restart the dev server after changing
.env - Check for typos in variable names
- Ensure no extra spaces around
=