BotNetwork

Environment variables and config for bots: 12-factor habits

A bot that starts without BOT_TOKEN should crash immediately, not at first message.

Guide1 min readUpdated

Rules

  1. Secrets only from the environment or a secret manager.
  2. Validate types and presence at process start.
  3. Commit .env.example, never .env.
  4. Different webhook URLs per environment (dev/stage/prod bots).

Tooling

Use the .env validator and secret strength tools while drafting examples.

Cloudflare Workers

Use wrangler secret put for tokens. Do not put secrets in wrangler.toml [vars].

Related comparisons and tools