Multi-Platform Gateway Architecture for Hermes Agent
The Multi-Platform Challenge
When you connect Hermes to Telegram, Discord, and Slack separately, each runs as an isolated process. This creates challenges:
- Duplicated context β The same question answered differently on each platform
- Memory fragmentation β Long-term memories don't sync across platforms
- Resource waste β Each connection maintains its own model instances
- Inconsistent behavior β Different configurations per platform
The solution is a unified gateway β a single Hermes instance that routes messages from all platforms through one intelligence layer.
Gateway Architecture Overview
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Telegram β β Discord β β Slack β
β Adapter β β Adapter β β Adapter β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Message Router β
β βββββββββββ ββββββββββββ ββββββββββββββββββββ β
β β Auth & β β Session β β Rate Limiter β β
β β ACL β β Manager β β β β
β βββββββββββ ββββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Hermes Agent Core β
β ββββββββββββ ββββββββββββ ββββββββββββββββββ β
β β AI Model β β Memory β β Skills Engine β β
β β Router β β System β β β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Setting Up the Gateway
Configuration
Enable gateway mode in your config:
# ~/.hermes/config.yaml
gateway:
enabled: true
port: 8080 # Internal API port
mode: "unified" # unified | isolated
# Unified session strategy
session_strategy: "per-user" # per-user | per-platform | shared
# per-user: Same user gets same context across platforms
# per-platform: Each platform has independent sessions
# shared: Everyone shares one session
# User identity mapping
identity_mapping:
enabled: true
# Map the same person across platforms
users:
- name: "Alice"
telegram_id: 123456789
discord_id: "987654321098765432"
slack_id: "U01ABCDEF"
- name: "Bob"
telegram_id: 987654321
discord_id: "123456789098765432"
# Platform adapters
adapters:
telegram:
enabled: true
bot_token: "7123456789:AAH..."
priority: 1 # Lower = higher priority for notifications
discord:
enabled: true
bot_token: "MTIzNDU2Nzg5MDEy..."
priority: 2
slack:
enabled: true
bot_token: "xoxb-..."
signing_secret: "..."
priority: 3
# Routing rules
routing:
# Auto-forward critical alerts to all platforms
broadcast_alerts: true
alert_channels:
telegram: [123456789] # User IDs
discord: ["1234567890123456789"] # Channel IDs
slack: ["C01234ABCDE"] # Channel IDs
# Default model per context
model_routing:
code_review: "anthropic/claude-3.5-sonnet"
quick_answers: "openai/gpt-4o-mini"
default: "anthropic/claude-3.5-sonnet"
Starting the Gateway
# Start all adapters through the gateway
hermes gateway start
π Hermes Gateway started!
Port: 8080
Mode: Unified
Session strategy: per-user
Adapters:
β
Telegram (@my_hermes_bot)
β
Discord (Hermes AI#1234)
β
Slack (My Company)
Identity mappings: 2 users
Routing rules: 3 active
Gateway ready. All platforms connected.
Message Routing
How Messages Flow
When a message arrives from any platform:
Platform-Specific Formatting
Each platform has different formatting capabilities. The gateway automatically adapts:
Hermes response (internal):
"Here's a Python function:\n
python\ndef hello():\n print('Hi')\n``"
β Telegram: Markdown with monospace code block
β Discord: Discord-flavored markdown with syntax highlighting
β Slack: Slack mrkdwn with
`preformatted` blocks
β WhatsApp: Plain text with indented code (no syntax highlighting)
Smart Model Routing
The gateway can automatically choose the best model based on the message content:
yaml
gateway:
smart_routing:
enabled: true
rules:
- pattern: "review|debug|fix|refactor"
model: "anthropic/claude-3.5-sonnet"
reason: "Code tasks need a strong model"
- pattern: "translate|summarize|explain"
model: "openai/gpt-4o-mini"
reason: "Simple tasks, save costs"
- pattern: "image|picture|photo|screenshot"
model: "openai/gpt-4o"
reason: "Multimodal capability needed"
- default:
model: "openai/gpt-4o-mini"
Cross-Platform Features
Unified Memory
With identity mapping, a user's memories persist across all platforms:
[Telegram] You: /memory save I prefer Python over JavaScript
β
Saved to long-term memory
[Discord] You: /ask Write me a web scraper
Hermes: Based on your preference, here's a Python web scraper...
# (Remembers the preference saved on Telegram!)
Cross-Platform Notifications
Send alerts or cron results to any platform:
yaml
cron:
tasks:
- name: "Daily server health check"
schedule: "0 9 *"
command: "Check server status and report issues"
notify:
telegram: [123456789] # Send to my phone
slack: ["C01234ABCDE"] # Post to #ops channel
discord: ["1234567890123456789"] # Post to #alerts
Message Forwarding
Forward conversations between platforms:
[Slack] Alice: @Hermes summarize the Q4 planning thread
[Hermes Response in Slack]
Summary: The team agreed on 3 priorities...
# If forwarding is enabled, this can also appear in:
[Discord #planning-updates] Hermes: [From Slack #general]
Summary from Alice's request: The team agreed on...
Production Deployment
Docker Compose
yaml
# docker-compose.yml
version: '3.8'
services:
hermes-gateway:
image: hermes-agent:latest
command: gateway start
restart: always
environment:
- HERMES_API_KEY=sk-or-v1-your-key
- HERMES_TELEGRAM_TOKEN=7123456789:AAH...
- HERMES_DISCORD_TOKEN=MTIzNDU2Nzg5MDEy...
- HERMES_SLACK_TOKEN=xoxb-...
volumes:
- hermes-data:/root/.hermes
ports:
- "8080:8080"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
hermes-data:
bash
docker compose up -d
Monitoring
The gateway exposes a health and metrics endpoint:
bash
# Health check
curl http://localhost:8080/health
# Metrics
curl http://localhost:8080/metrics
json
{
"status": "healthy",
"uptime": "48h 23m",
"adapters": {
"telegram": { "status": "connected", "messages_today": 142 },
"discord": { "status": "connected", "messages_today": 89 },
"slack": { "status": "connected", "messages_today": 203 }
},
"ai_usage": {
"tokens_today": 450000,
"cost_today": "$1.23",
"avg_response_time": "2.1s"
}
}
Error Handling and Resilience
The gateway handles adapter failures gracefully:
yaml
gateway:
resilience:
# Retry failed messages
max_retries: 3
retry_delay: 5000 # ms
# Circuit breaker
circuit_breaker:
enabled: true
failure_threshold: 5 # Consecutive failures before opening
reset_timeout: 60000 # ms before attempting reconnect
# Fallback behavior
fallback:
# If one adapter fails, notify through others
notify_other_platforms: true
message: "β οΈ {platform} adapter is temporarily down. I'm still available on other platforms."
Scaling Considerations
Single Instance (1-10 users)
The default setup handles small teams easily:
bash
hermes gateway start
Medium Scale (10-100 users)
Use PM2 cluster mode:
bash
pm2 start "hermes gateway start" --name hermes-gw -i 2
Large Scale (100+ users)
For large deployments, separate adapters from the core:
[Telegram Adapter] βββ [Redis Queue] βββ [Hermes Worker Pool]
[Discord Adapter] βββ [Redis Queue] βββ [Hermes Worker Pool]
[Slack Adapter] βββ [Redis Queue] βββ [Hermes Worker Pool]
yaml
gateway:
queue:
enabled: true
backend: "redis"
redis_url: "redis://localhost:6379"
workers: 4
Security Architecture
Internet
β
βΌ
[Firewall / Cloudflare]
β
βΌ
[SSL Termination (nginx)]
β
βΌ
[Rate Limiter]
β
βΌ
[Auth Layer] β Validates platform tokens, user ACL
β
βΌ
[Hermes Gateway] β Sandboxed file system access
β
βΌ
[AI Model Provider] β API key encrypted at rest
``
Key security measures:
- [ ] All platform tokens encrypted at rest
- [ ] Per-user rate limiting across platforms
- [ ] File system sandboxing
- [ ] Audit logging for all interactions
- [ ] Regular credential rotation
Next Steps
- Telegram setup β Start with one platform
- Multi-agent orchestration β Run multiple agents through the gateway
- Server monitoring β Get alerts via the gateway
Last updated: April 16, 2026 Β· Hermes Agent v0.8