The Hermes Agent Cookbook
Free recipes / Messaging and Gateways

Lock the Gateway to Your Own Account

A file snippet for ~/.hermes/.env that keeps the Hermes gateway on deny by default and lets in only your own accounts, with the steps to test it.

You are connecting Hermes to Telegram, Discord, Slack or WhatsApp and want to be sure a stranger who finds your bot cannot use it. Saves about 15 minutes

The recipe

# ~/.hermes/.env : who may talk to Hermes through the gateway # Hermes denies everyone by default. Each line below lets in only the # accounts listed. Separate several IDs with commas, no spaces. # Lines starting with # are ignored, so remove the # only on the # platforms you actually use. TELEGRAM_ALLOWED_USERS=[TELEGRAM_ID] # DISCORD_ALLOWED_USERS=[DISCORD_ID] # SLACK_ALLOWED_USERS=[SLACK_ID] # WHATSAPP_ALLOWED_USERS=[WHATSAPP_NUMBER] # GATEWAY_ALLOWED_USERS is a cross-platform list that is checked on every # platform. The per-platform lines above are clearer; leave it out unless # you know you need it. # # Never add an allow-all setting, here or in config.yaml. Hermes can run # commands on this machine, so anyone who found your bot could too. # # After saving: # chmod 600 ~/.hermes/.env # hermes gateway restart # # Then test from a second account, or ask a friend to message your bot. # It must not answer. At most an unknown person gets a pairing code, and # nothing happens unless you run hermes pairing approve yourself. Codes # expire after one hour. Check who you have approved with # hermes pairing list now and then, and remove anyone with # hermes pairing revoke <platform> <user_id>.

Fill in these brackets

[TELEGRAM_ID]e.g. 123456789 (numeric user ID, not your @username)
[DISCORD_ID]e.g. 111222333444555666 (turn on Developer Mode, then right-click your name and copy your user ID)
[SLACK_ID]e.g. U01ABC123 (your member ID, shown in your Slack profile)
[WHATSAPP_NUMBER]e.g. 15551234567 (country code first, digits only)

Pro tip

Use IDs, not usernames. A Telegram @username can be changed or taken over; the numeric ID stays with your account.

Variation

Using email instead? Add EMAIL_ALLOWED_USERS with your own addresses, comma-separated, or enter them when hermes gateway setup asks for allowed senders. The docs require a dedicated mailbox for Hermes, so never connect your personal one.

Written for Hermes Agent v0.21.x. Check commands against your version with hermes --version. This site is independent and not affiliated with Nous Research.

Want 14 more like this, free?

Get the Hermes Starter Pack: 15 recipes for setup, SOUL.md, memory, skills, scheduled jobs, Telegram and approvals.

More free recipes: Set Up Telegram With Hermes Safely · Use the Email Gateway for Forwarded Messages

No spam. Confirm your email with one click and the PDF is yours.

Need the whole set? The Hermes Agent Cookbook has 100 recipes for $27.