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.
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
Quick Setup
Required Variables
These must be set for the application to start.Database Connection
- Using Docker (Recommended)
- External Database
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
Add to .env
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
Get your API key
- Navigate to API Keys in the dashboard 2. Click Create Key 3. Copy the key (starts
with
sk-ant-)
Add to .env
Option 2: OpenAI (GPT)
Create an OpenAI account
Get your API key
- Go to API Keys section 2. Click Create new secret key 3. Copy the key (starts with
sk-)
Add to .env
bash OPENAI_API_KEY=sk-your-key-here LLM_MODEL_OPENAI=gpt-4o-mini LLM_PROVIDER=openai LLM Settings
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
Choose creation method
Get Signing Secret
SLACK_SIGNING_SECRET - Copy Client ID and Client Secret (needed for OAuth login
on web dashboard)Enable Socket Mode
Navigate to Socket Mode
Enable Socket Mode
Create App-Level Token
- Click Generate Token and Scopes 2. Give it a name (e.g., “socket-token”) 3. Add the
connections:writescope 4. Click Generate 5. Copy the token (starts withxapp-) → This is yourSLACK_APP_TOKEN
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
Copy Bot Token
xoxb-) → This is
your SLACK_BOT_TOKENConfigure Event Subscriptions
Enable Events
Subscribe to Bot Events
app_home_opened - App home tab views - app_mention- @mentions in channels -
message.im- Direct messages
Save Changes
Create Slash Command (Optional)
Go to Slash Commands
Create Command
- Click Create New Command 2. Command:
/hitler3. Short Description: “Interact with Hitler” 4. Click Save
Add All Credentials to .env
Run the Bot
Email Configuration (Optional)
For sending email notifications (password resets, alerts, etc.).Option 1: Resend (Recommended)
Create a Resend account
Get your API key
Verify your domain
Add to .env
bash RESEND_API_KEY=re_123456789 EMAIL_FROM=notifications@yourdomain.com 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
Create a KV namespace
- Go to Workers & Pages → KV
- Click Create a namespace
- Name it (e.g., “hitler-secrets-prod”)
- Copy the Namespace ID
Get your Account ID
Create an API token
- Go to My Profile → API Tokens
- Click Create Token
- Use Edit Cloudflare Workers template
- Copy the token
Generate encryption key
Add to .env
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
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.Task Configuration
Logging
Complete .env Template
Here’s a complete template with all variables:Security Best Practices
Never commit .env
.gitignore already excludes .env files. Never override this.Use different secrets per environment
Rotate secrets regularly
Use a secrets manager in production
Troubleshooting
App won't start - missing DATABASE_URL
App won't start - missing DATABASE_URL
.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
bash node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" LLM returns mock responses
LLM returns mock responses
ANTHROPIC_API_KEY or OPENAI_API_KEY for real LLM responses.Slack bot won't start
Slack bot won't start
- 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
=