Hermes Agent + Discord: Build a Community AI Bot
Why Discord + Hermes?
Discord is where developer communities live. Adding Hermes Agent to your Discord server transforms it into an AI-powered knowledge hub:
- Slash commands β
/ask,/code,/explainfor quick interactions - Thread support β Long conversations in threads keep channels clean
- Role-based access β Control who can use the bot
- Rich formatting β Code blocks, embeds, and interactive buttons
- Multi-channel β Different channels for different topics
Prerequisites
- Hermes Agent installed and configured
- A Discord account with server admin privileges
- Node.js 18+ installed
- An AI model configured
Step 1: Create a Discord Application
Register Your Bot
MTIzNDU2Nzg5MDEy...your-bot-token-here
Security note: Never share or commit this token. Anyone with it can control your bot.
Set Bot Permissions
In the Bot section:
- Enable Message Content Intent (required to read messages)
- Enable Server Members Intent (for role-based access)
Generate Invite Link
Go to OAuth2 β URL Generator:
bot, applications.commands- Send Messages
- Send Messages in Threads
- Create Public Threads
- Create Private Threads
- Embed Links
- Attach Files
- Read Message History
- Use Slash Commands
- Add Reactions
Step 2: Configure Hermes
# Set Discord bot token
hermes config set discord.bot_token "MTIzNDU2Nzg5MDEy...your-token"
hermes config set discord.enabled true
# Restrict to specific channels (optional but recommended)
hermes config set discord.allowed_channels "[1234567890123456789]"
Full Discord Configuration
# ~/.hermes/config.yaml
discord:
enabled: true
bot_token: "MTIzNDU2Nzg5MDEy..."
# Access control
allowed_channels: [1234567890123456789] # Channel IDs
allowed_roles: ["AI-User", "Developer"] # Role names
admin_roles: ["Admin", "Moderator"] # Can manage bot settings
# Behavior
respond_to_mentions: true # Respond when @mentioned
respond_to_dms: true # Respond to direct messages
use_threads: true # Create threads for long conversations
thread_auto_archive: 1440 # Auto-archive threads after 24h (minutes)
# Rate limiting
max_requests_per_user: 30 # Per hour
cooldown_seconds: 5 # Between messages
# Display
embed_color: "#d97706" # Hermes brand amber
show_model_info: true # Show which model is responding
show_token_usage: false # Show token count (admin only)
Step 3: Register Slash Commands
Hermes auto-registers slash commands when it starts. Here are the defaults:
| Command | Description |
|---------|-------------|
| /ask | Ask Hermes a question |
| /code | Generate code |
| /explain | Explain code or a concept |
| /review | Review code (with file attachment) |
| /model | Switch AI model |
| /session | Manage sessions |
| /help | Show all commands |
Step 4: Start the Bot
Test Mode
hermes discord start
π€ Discord bot online!
Bot: Hermes AI#1234
Servers: 2
Channels: 3 (allowed)
Slash commands: 7 registered
Ready and listening...
Production Mode with PM2
pm2 start "hermes discord start" --name hermes-discord
pm2 save
Using Docker
FROM node:18-alpine
RUN npm install -g hermes-agent
COPY config.yaml /root/.hermes/config.yaml
CMD ["hermes", "discord", "start"]
docker build -t hermes-discord .
docker run -d --name hermes-discord \
-e HERMES_API_KEY=sk-or-v1-your-key \
hermes-discord
Step 5: Using Hermes on Discord
Slash Commands
/ask How do I implement JWT authentication in Express?
/code python Create a web scraper for Hacker News top stories
/explain
const memoize = (fn) => {
const cache = new Map();
return (...args) => {
const key = JSON.stringify(args);
if (cache.has(key)) return cache.get(key);
const result = fn(...args);
cache.set(key, result);
return result;
};
};
/review (attach a file)
@Mention Mode
When respond_to_mentions is enabled:
@Hermes AI What's the best way to handle file uploads in Next.js?
Hermes responds in a thread to keep the channel organized.
Thread Conversations
When threads are enabled, the first response creates a thread. All follow-ups happen in the thread:
Channel: #dev-help
βββ User: @Hermes AI Help me deploy to AWS
β βββ [Thread: Deploy to AWS]
β βββ Hermes: Sure! Let me help you with AWS deployment...
β βββ User: I want to use ECS
β βββ Hermes: Great choice! Here's the ECS setup...
β βββ User: How about the load balancer?
Advanced Configuration
Role-Based Model Access
Give different users access to different models:
discord:
role_models:
"Free-Tier": "openai/gpt-4o-mini" # Budget model
"Developer": "anthropic/claude-3.5-sonnet" # Full access
"Admin": "anthropic/claude-3.5-sonnet" # Full access + settings
Custom Slash Commands
Define your own slash commands:
discord:
custom_commands:
- name: "translate"
description: "Translate text to another language"
template: "Translate the following to {language}: {text}"
parameters:
- name: "text"
type: "string"
required: true
- name: "language"
type: "string"
required: true
choices: ["English", "Chinese", "Japanese", "Spanish"]
- name: "summarize"
description: "Summarize a URL or text"
template: "Summarize this concisely: {input}"
Channel-Specific Contexts
Give Hermes different personas per channel:
discord:
channel_contexts:
1234567890: # #coding-help
system_prompt: "You are a coding assistant. Always provide code examples."
model: "anthropic/claude-3.5-sonnet"
9876543210: # #general
system_prompt: "You are a friendly AI assistant. Keep responses brief."
model: "openai/gpt-4o-mini"
Security Best Practices
- [ ] Set
allowed_channelsto prevent bot from responding everywhere - [ ] Configure
allowed_rolesfor access control - [ ] Enable rate limiting to prevent API credit abuse
- [ ] Use environment variables for the bot token
- [ ] Monitor bot usage with
show_token_usage(admin only) - [ ] Restrict file system access in Hermes config
Troubleshooting
Bot appears offline
# Check if process is running
pm2 status hermes-discord
# Verify the token
hermes discord test
# Check Discord Developer Portal for any issues
Slash commands not appearing
Slash commands can take up to 1 hour to propagate globally. For immediate testing, use guild-specific commands:
hermes discord register-commands --guild 1234567890
Permission errors
Make sure the bot has the required permissions in the channel:
- Check server settings β Roles β Bot role
- Check channel permissions β Bot role overrides
Next Steps
- Telegram integration β Add mobile access
- Multi-platform gateway β Unify all messaging platforms
- Automated daily reports β Get AI reports in Discord
Last updated: April 16, 2026 Β· Hermes Agent v0.8