Home / Blog / How to connect Hermes Agent to Telegram (step by step)
From zero to talking to your agent on your phone.

How to connect Hermes Agent to Telegram (step by step)

Most people who run Hermes Agent use Telegram as their main interface. You message the bot from your phone like you'd message anyone, and the agent responds. Getting this set up takes about 10 minutes.

Hermes OS team21 April 20267 min read

What you need first

  • A Telegram account (download here if you don't have one — it's free)
  • Hermes Agent installed (self-hosted or via Hermes OS, which handles Telegram setup through the dashboard)
  • Your Telegram User ID — you'll get this in step 2

Step 1: Create your bot with BotFather

BotFather is Telegram's official tool for creating other bots. Open Telegram, search for @BotFather — it has a blue verified checkmark — and send it: /newbot

It asks for:

  1. A name for your bot (display name, anything you like — 'My Hermes Agent')
  2. A username (must end in bot, must be unique across Telegram — 'myhermesagent_bot')

Once created, BotFather sends your bot token. It looks like: 1234567890:AAFxxxxxxxxxxxxxxxxxx

Copy it somewhere safe.

Keep the bot token private. Anyone with this token controls your bot. Don't paste it into chat, don't commit it to a public repo, don't include it in screenshots.

If you think it's been compromised: BotFather → /mybots → select your bot → API Token → Revoke. Generates a new token instantly, invalidates the old one.

Step 2: Find your Telegram User ID

Your User ID is a number, not your @username. It's how Hermes knows which accounts to respond to.

Open Telegram, search for @userinfobot, and send it any message. It replies with your numeric User ID — something like 123456789.

If you want multiple people to use your bot, collect all their User IDs now.

This matters because without an allowlist, anyone who finds your bot can send it commands. Hermes has access to your server's filesystem and terminal. Setting the User ID allowlist is the main security step — everything else is configuration.

Step 3: Add credentials to Hermes

Open the Hermes environment file:

bash
nano ~/.hermes/.env

Add these two lines:

TELEGRAM_BOT_TOKEN=1234567890:AAFxxxxxxxxxxxxxxxxxx TELEGRAM_ALLOWED_USERS=123456789

Multiple users:

TELEGRAM_ALLOWED_USERS=123456789,987654321

Save (in nano: Ctrl+O → Enter → Ctrl+X). Or run the interactive wizard which handles all of this:

bash
hermes gateway setup

Step 4: Start the gateway

Test it first:

bash
hermes gateway

You should see output showing the Telegram listener started. Open Telegram, find your bot by username, send it something — 'Hello' or 'What can you do?'

If it responds, it's working. Press Ctrl+C to stop the test.

Now install it as a background service:

bash
hermes gateway install hermes gateway start hermes gateway status

From this point the gateway runs in the background. Close the terminal. Messages sent to your bot on Telegram reach the agent, it runs the task, it replies.

If messages don't arrive

Bot doesn't respond at all:

  • Check the gateway is running: hermes gateway status
  • Verify the bot token is complete (no truncation, no trailing space)
  • Confirm your User ID is in TELEGRAM_ALLOWED_USERS — it's a number, not your @username

Error: 'Unauthorized':

  • Bot token is wrong or revoked. Check it in BotFather: /mybots → your bot → API Token.

Error: 'User not in allowlist':

  • Your User ID isn't in the list. Double-check with @userinfobot that you got the right number.

Gateway starts then crashes:

  • Check logs: journalctl --user -u hermes-gateway -f (Linux with systemd)
  • Or: tail -f ~/.hermes/logs/gateway.log

Optional: use a dedicated phone number

If you already use Telegram bots for other things, consider creating a completely separate Telegram account just for Hermes. Separate phone number, separate identity.

Benefits: cleaner notification management, lower risk to your personal account, easier to share with colleagues. Not required for personal use — this is mainly worth it if you're running it for a team.

What to say to it

Once connected, just message it. Some starting points:

  • 'What can you do?' — lists capabilities and installed skills
  • 'Remember that my name is [name] and I work as a [role]' — seeds the memory file
  • 'Check if google.com is reachable' — tests tool execution
  • 'Send me a Telegram message every weekday at 8am with a brief weather summary for [city]' — sets up a scheduled task

For a broader look at what people use it for day to day: 12 real use cases here. For connecting other platforms alongside Telegram: the full gateway guide.

On Hermes OS

If you're using Hermes OS instead of self-hosting, Telegram setup is in the dashboard. Paste your bot token and User ID, click save. No SSH, no .env editing, no terminal.

Common questions

Do I need to install Telegram on the server?

No. Telegram is on your phone. The Hermes gateway connects to Telegram's API over the internet — no Telegram installation on the server itself.

Can I use the same Telegram bot with two Hermes instances?

No. One bot token, one gateway at a time. Two separate Hermes instances need two separate bots — each with their own token from BotFather.

Is there a message rate limit?

Telegram limits bots to roughly 30 messages/second to different users, 1/second to the same user. For personal use this never matters. Hermes handles standard rate limiting automatically.

What if I want to use it in a group chat?

Group access is off by default. Enable with TELEGRAM_ALLOW_GROUPS=true. Anyone in the group who's on your allowlist can send it commands — worth thinking through before enabling.

Can anyone find my bot and use it?

They can find it by username search, but Hermes will not respond to User IDs not in TELEGRAM_ALLOWED_USERS. Unknown users get no response. Alternatively, enable DM pairing (hermes pairing) — unknown users get a time-limited code you approve before they get access.

Deploy in 5 minutes.

7-day money-back guarantee. BYO AI key. From $19/mo.

Start Now
Related reading
All 15 Hermes Agent gateways: full setup guideWhat can Hermes Agent actually do?Hermes Agent scheduled tasksHow to self-host Hermes Agent on a VPS