Skip to content

Variables and secrets

Your bot reads its settings from environment variables. Set them on the bot's Variables tab.

Add a variable

  1. Open Variables and press Add variable.
  2. Enter the name (letters, digits and _, not starting with a digit; up to 100 characters) and the value (one line, up to 4096 characters). A bot can have up to 100 variables.
  3. Keep Mark as Secret on for tokens, passwords and API keys: the value stays hidden in the list until you open it.

Read it in your code with os.environ["NAME"] (Python) or process.env.NAME (Node.js).

When changes take effect

Variables are passed to the container when it is created. A change reaches the bot when you:

  • deploy again, or
  • stop and start the deployment.

Restart keeps the container, and with it the old values.

Variables BotBarn sets

Name Value
TELEGRAM_BOT_TOKEN Your bot's token, saved from the Telegram card. You can change it.
BOTBARN_BOT_ID The id of this bot on BotBarn.
PORT, BOTBARN_WEBHOOK_URL, BOTBARN_WEBHOOK_SECRET Only when webhooks are enabled: Polling or webhook.
BOTBARN_WEBHOOK_MANAGED 1 when BotBarn registers the webhook (webhook mode), 0 otherwise.

Names starting with BOTBARN_, and PORT, are reserved: you cannot add them yourself.

Earlier versions also gave every bot an API key variable. It is gone, because no BotBarn service ever accepted it: a bot whose code still reads it gets nothing after its next deploy.

Keeping secrets secret

  • Never put tokens or passwords in your repository or archive. Use variables.
  • BotBarn stores variable values encrypted and replaces every value of 6 characters or more with *** in build logs and bot logs.
  • If a secret leaks, change it at its source (for example /revoke in BotFather), update the variable, and deploy again.