4 min read

Building a Personal AI Assistant on Telegram with Hermes Agent

#AI#Telegram#Hermes#Self-Hosting

Imagine having an AI assistant that isn't tethered to your laptop terminal. You're out grabbing coffee, you open Telegram, text "check server disk usage and active docker containers," and it genuinely executes the task—running directly on your remote VPS. That practical hook led me to explore Hermes Agent by Nous Research.

Hermes is an AI agent designed to grow with you through an integrated learning loop: it synthesizes reusable skills from execution history, retains persistent memory across conversations, and runs on environments ranging from a $5 VPS to dedicated GPU clusters. Crucially, it provides a unified gateway for messaging platforms like Telegram, Discord, Slack, and WhatsApp. Here is how to set it up on Telegram for daily workflow automation.

Installing Hermes

The installation process runs seamlessly on modern Linux distributions (as well as macOS and WSL2). The official one-liner bundles runtime dependencies including uv, Python 3.11, Node.js, ripgrep, and ffmpeg:

curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash

Reload your shell configuration to bring the hermes binary into your environment:

source ~/.bashrc   # or source ~/.zshrc on zsh

Validate system health using the built-in diagnostic tool:

hermes doctor

Configuring LLM Providers

Hermes operates model-agnostically, supporting OpenRouter, OpenAI, Nous Portal, and self-hosted vLLM or Ollama endpoints:

hermes setup

The interactive wizard guides you through selecting your preferred provider, entering API keys, and picking default models. If you subscribe to Nous Portal, running hermes setup --portal automatically configures unified access to models, web search, image synthesis, and TTS without managing individual third-party API accounts.

To test terminal interaction first, invoke hermes to launch the terminal user interface (TUI).

Creating a Telegram Bot via BotFather

Every Telegram bot requires an authentication token issued by @BotFather:

  1. Open Telegram and start a chat with @BotFather.
  2. Send the /newbot command and follow the prompts to choose a display name and username.
  3. BotFather returns an API token formatted like: 123456789:ABCdefGHIjklMNOpqrSTUvwxYZ.

Treat this bot token as a sensitive secret. Anyone holding the token can intercept incoming messages and control bot behavior.

Locating Your Telegram User ID

By default, Hermes enforces a strict user allowlist. Because the agent possesses shell execution capabilities on your server, arbitrary users must not interact with the bot.

To find your numerical Telegram User ID, send a message to @userinfobot or @get_id_bot. It will reply immediately with your personal numeric ID.

Connecting Telegram to Hermes

Return to your server and initialize the gateway wizard:

hermes gateway setup

Select Telegram from the menu. Provide your BotFather token and numerical user ID when prompted. The configuration is stored securely:

TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrSTUvwxYZ
TELEGRAM_ALLOWED_USERS=123456789    # Comma-separated for multiple authorized IDs

Launching the Gateway

Test connectivity in the foreground:

hermes gateway

Hermes uses long-polling to retrieve messages from Telegram's servers, eliminating the need to expose inbound webhooks or open dedicated firewall ports. Send a message to your bot on Telegram, and verify the response.

Running Permanently as a System Service

To keep your assistant active after closing your SSH terminal, install the gateway as a managed background service:

hermes gateway install   # Configures a systemd user service on Linux
hermes gateway start
hermes gateway status

On Linux, enable user lingering so systemd keeps your user services alive after logout:

sudo loginctl enable-linger $USER

Monitor live logs at any time:

journalctl --user -u hermes-gateway -f

Practical Interactions & Daily Automation

With the bot operational, your Telegram chat serves as an interactive command interface. Useful slash commands include:

  • /new or /reset — Clears context and starts a fresh conversation.
  • /model — Switches underlying LLMs on the fly without service restarts.
  • /usage — Displays current session token consumption.
  • /stop — Aborts an ongoing tool execution.
  • /approve and /deny — Confirms or rejects privileged commands before the agent executes them on the host.

Beyond reactive queries, Hermes features an integrated cron scheduler. You can schedule autonomous recurring tasks in natural language, such as: "Every morning at 07:00, check server disk usage and message me a summary." Automated backups, daily health audits, and monitoring notifications are delivered straight to your chat without third-party monitoring subscriptions.

Summary

Self-hosting Hermes Agent gives you a responsive, persistent AI assistant accessible from mobile devices anytime. Running directly on your server allows the agent to handle real operational chores, while strict user allowlists and approval gates ensure secure execution.

For extended features including custom skills, persistent memory stores, and MCP tools, explore the Hermes Agent Documentation.