Skip to main content

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

  1. You create a .env file in the project root
  2. The app loads these values at startup
  3. 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

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
1

Generate a secure secret

Run this command in your terminal:
This outputs a 64-character hex string like:
2

Add to .env

Never use the example value in production! Generate a unique secret for each environment.

LLM Configuration

Hitler uses LLMs for natural language task parsing. You need at least one provider configured.
1

Create an Anthropic account

Go to console.anthropic.com and sign up.
2

Get your API key

  1. Navigate to API Keys in the dashboard 2. Click Create Key 3. Copy the key (starts with sk-ant-)
3

Add to .env

Available Models:

Option 2: OpenAI (GPT)

1

Create an OpenAI account

Go to platform.openai.com and sign up.
2

Get your API key

  1. Go to API Keys section 2. Click Create new secret key 3. Copy the key (starts with sk-)
3

Add to .env

bash OPENAI_API_KEY=sk-your-key-here LLM_MODEL_OPENAI=gpt-4o-mini LLM_PROVIDER=openai
Available Models:

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

1

Go to Slack API

Visit api.slack.com/apps and click Create New App.
2

Choose creation method

Select From scratch, enter a name (e.g., “Hitler Dev”), and select your workspace.
3

Get Signing Secret

In Basic Information, scroll to App Credentials: - Copy Signing Secret → This is your SLACK_SIGNING_SECRET - Copy Client ID and Client Secret (needed for OAuth login on web dashboard)

Enable Socket Mode

1

Navigate to Socket Mode

In your Slack App settings, click Socket Mode in the left sidebar.
2

Enable Socket Mode

Toggle Enable Socket Mode to ON.
3

Create App-Level Token

  1. Click Generate Token and Scopes 2. Give it a name (e.g., “socket-token”) 3. Add the connections:write scope 4. Click Generate 5. Copy the token (starts with xapp-) → This is your SLACK_APP_TOKEN
The App-Level Token is only shown once! Save it immediately to your .env file.

Configure OAuth Scopes

In your Slack App settings, go to OAuth & Permissions: Bot Token Scopes (required):
User Token Scopes (for OAuth login on web dashboard):

Install to Workspace and Get Bot Token

1

Install the App

  1. Go to Install App in the left sidebar 2. Click Install to Workspace 3. Authorize the requested permissions
2

Copy Bot Token

After installation, you’ll see Bot User OAuth Token. Copy it (starts with xoxb-) → This is your SLACK_BOT_TOKEN

Configure Event Subscriptions

1

Enable Events

Go to Event Subscriptions and toggle Enable Events on.
2

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
3

Save Changes

Click Save Changes at the bottom.
With Socket Mode, you don’t need to set a Request URL - events are delivered over the WebSocket connection.

Create Slash Command (Optional)

1

Go to Slash Commands

Click Slash Commands in the left sidebar.
2

Create Command

  1. Click Create New Command 2. Command: /hitler 3. Short Description: “Interact with Hitler” 4. Click Save

Add All Credentials to .env

Run the Bot

You should see:
Now you can DM your bot in Slack or @mention it in channels!

Email Configuration (Optional)

For sending email notifications (password resets, alerts, etc.).
1

Create a Resend account

Go to resend.com and sign up.
2

Get your API key

In the dashboard, go to API Keys and create a new key.
3

Verify your domain

Add DNS records to verify your sending domain.
4

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.):
For Gmail, you need to create an App Password, not your regular password.

Secrets Storage (Production)

In production, platform OAuth tokens (Slack) are stored encrypted in Cloudflare KV.

Set Up Cloudflare KV

1

Create a Cloudflare account

Go to cloudflare.com and sign up.
2

Create a KV namespace

  1. Go to Workers & PagesKV
  2. Click Create a namespace
  3. Name it (e.g., “hitler-secrets-prod”)
  4. Copy the Namespace ID
3

Get your Account ID

Find it in the right sidebar of any Cloudflare page, or in Account Home.
4

Create an API token

  1. Go to My ProfileAPI Tokens
  2. Click Create Token
  3. Use Edit Cloudflare Workers template
  4. Copy the token
5

Generate encryption key

This outputs a base64-encoded 32-byte key.
6

Add to .env

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)

Get a key from jina.ai. Used to fetch and extract content from URLs shared in channels. Falls back to @extractus/article-extractor if Jina is unavailable.

Web Search (Tavily)

Get a key from tavily.com. Used by the 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.
Example configurations:

Task Configuration

Task drafts that aren’t confirmed within this time are automatically deleted.

Logging


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

Ensure you’ve copied .env.example to .env and the database is running:
Generate a proper secret: bash node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
You need to set either ANTHROPIC_API_KEY or OPENAI_API_KEY for real LLM responses.
“You must provide an appToken” error:
  • Set SLACK_APP_TOKEN in your .env (starts with xapp-)
  • Generate one in Slack App → Socket Mode → App-Level Tokens
“Invalid token” error:
  • Verify SLACK_BOT_TOKEN is correct (starts with xoxb-)
  • Re-install the app to your workspace if needed
  1. Ensure Socket Mode is enabled in your Slack App settings 2. Verify Event Subscriptions has message.im and app_mention subscribed 3. For channel messages, the bot must be invited to the channel 4. Check that SLACK_SIGNING_SECRET matches your app
  1. Restart the dev server after changing .env
  2. Check for typos in variable names
  3. Ensure no extra spaces around =