HAL runs one Telegram bot per project. You need two things before starting:
- A bot token — so Telegram knows which bot your config is running.
- Your user ID — required so the bot can restrict access and associate your messages with your session.
Follow the two sections below. Both are required to set up your first project.
You get a bot token from BotFather, Telegram’s official bot for creating and managing bots.
- In Telegram (app or desktop), search for @BotFather or open: https://t.me/BotFather.
- Start a chat and send any message if prompted.
- Send the command:
/newbot - Display name — BotFather will ask for a name that users see (e.g. “My Backend Assistant”). This can be changed later.
- Username — Next, choose a username that must end in
bot(e.g.my_backend_assistant_bot). It must be unique across Telegram and cannot be changed later.
- BotFather will reply with a token that looks like:
7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Copy this token and keep it secret. Anyone with the token can control your bot.
- You can get the token again later by sending
/mybotsto BotFather, selecting your bot, then API Token.
-
Do not put the token directly in your config file if it is committed to git.
-
Put it in a
.envfile in the same directory as your config (the directory where you run the HAL CLI), and do not commit that file. Example:# .env (create this file next to hal.config.yaml, keep it out of git) BACKEND_BOT_TOKEN=7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
In your config, reference it with a placeholder:
projects: backend: cwd: ./backend telegram: botToken: "${BACKEND_BOT_TOKEN}"
-
HAL resolves
${BACKEND_BOT_TOKEN}at startup from.env(or.env.localif you use it, or the shell environment). See Env files for details on loading precedence and.gitignoreguidance.
Each HAL project uses a separate bot and token. If you have two projects (e.g. backend and frontend), create two bots with BotFather and use two different env vars and tokens in your config.
HAL uses your Telegram user ID (a numeric ID) for access control and per-user sessions. You need this number to add yourself to allowedUserIds so the bot accepts your messages. HAL refuses to start without an allowlist unless you explicitly opt into unrestricted access.
- In Telegram, open a chat with @userinfobot: https://t.me/userinfobot.
- Send any message (e.g. “Hi”).
- The bot replies with your profile info, including Id: followed by a number (e.g.
123456789). That number is your Telegram user ID.
-
In your config, set
allowedUserIdsso that only you (and any other allowed users) can use the bot. If the list is empty, HAL refuses to start unless you explicitly setdangerouslyAllowUnrestrictedAccess: true.Globally (all projects):
globals: access: allowedUserIds: [123456789]
Per project:
projects: backend: cwd: ./backend telegram: botToken: "${BACKEND_BOT_TOKEN}" access: allowedUserIds: [123456789]
-
Use your numeric ID (no quotes). You can add multiple IDs:
[123456789, 987654321]. -
You can also use strings so the value comes from the environment: e.g.
["${TELEGRAM_USER_ID}"]in config and setTELEGRAM_USER_ID=123456789in.env. Keep that file out of git. See Env files and Access control. -
Users whose ID is not in the list will not be able to use that bot when the allowlist is enabled.
- Restricts who can talk to your bot.
- Keeps your bot private for development or team use.
- Required for HAL’s access control; only use
dangerouslyAllowUnrestrictedAccess: trueif you intend to allow everyone (not recommended for tokens you care about).