Setting Up Telegram Bot

Complete guide to setting up the Telegram bot integration.

Step 1: Create a Bot

  1. Open Telegram and search for @BotFather
  2. Start a chat and send /newbot
  3. Follow the prompts:
    • Enter a name for your bot (e.g., “My Terminal Bot”)
    • Enter a username (must end in bot, e.g., my_terminal_bot)
  4. BotFather will give you a token like:
    123456789:ABCdefGHIjklMNOpqrsTUVwxyz
  5. Save this token — you’ll need it next

Step 2: Get Your User ID

  1. Open Telegram and search for @userinfobot
  2. Start a chat (or send any message)
  3. The bot will reply with your user ID:
    Your user ID: 987654321
  4. Save this ID

Step 3: Configure remote-terminal

Add to your .env file:

TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_ALLOWED_USERS=987654321

Step 4: Start the Server

npm start

You should see:

[telegram] Bot started (@your_bot_username)

Step 5: Test the Bot

  1. Open Telegram
  2. Search for your bot by username
  3. Send /start
  4. You should see the help message

Adding Multiple Users

Separate user IDs with commas:

TELEGRAM_ALLOWED_USERS=987654321,123456789,555555555

Customizing Commands

Edit config/default.json to add your own commands:

{
  "telegram": {
    "commands": {
      "deploy": {
        "cmd": "npm run deploy",
        "description": "Deploy to production"
      }
    }
  }
}

Security Tips

  • Never share your bot token — Anyone with it can control your bot
  • Only add trusted users — They get full shell access
  • Use a dedicated bot — Don’t reuse tokens from other projects