Building a Gateway Bot: Telegram, Discord, and Slack

9 min read Module 6 of 9 Topic 16 of 25

What you'll learn

  • Explain what the messaging gateway process does and how it relates to the main agent
  • Connect Telegram, Discord, and Slack bots to a single Hermes gateway
  • Understand what stays unified (sessions, tools) across every connected platform
  • Check gateway health and diagnose a disconnected platform adapter
Building this at your company? For enterprise and company teams taking this to production: book a 30-minute session with our AI engineers for architecture guidance, code review, and a rollout plan for your use case.
Book a Team Session

From CLI Agent to Platform Bot

Everything so far has run through hermes or hermes --tui, a single interactive session on your machine. The messaging gateway takes the same configured agent, same models, tools, memory, and skills, and exposes it as a bot on messaging platforms, so it’s reachable from wherever you already are, not just your terminal.

flowchart TB
    GW["Gateway process\n(single background service)"]
    TG["Telegram adapter"] <--> GW
    DC["Discord adapter"] <--> GW
    SL["Slack adapter"] <--> GW

    GW --> SESS[("Unified sessions")]
    GW --> AGENT["Same configured agent:\nmodels, tools, memory, skills"]

    style GW fill:#EEF0F7,stroke:#6366F1,color:#0F172A
    style TG fill:#f0fdf9,stroke:#0D9488,color:#0F172A
    style DC fill:#f0fdf9,stroke:#0D9488,color:#0F172A
    style SL fill:#f0fdf9,stroke:#0D9488,color:#0F172A
    style SESS fill:#fff7ed,stroke:#f59e0b,color:#0F172A
    style AGENT fill:#EEF0F7,stroke:#6366F1,color:#0F172A

Hermes’ gateway supports 27+ messaging platforms in total, this lesson covers the three most common: Telegram, Discord, and Slack. The pattern generalizes to every other adapter you’ll find in the docs.

Connecting Telegram

# ~/.hermes/.env
TELEGRAM_BOT_TOKEN=123456:ABC-...    # from @BotFather
# ~/.hermes/config.yaml
gateway:
  telegram:
    enabled: true
hermes gateway start

Connecting Discord

# ~/.hermes/.env
DISCORD_BOT_TOKEN=...
gateway:
  discord:
    enabled: true
    # optional: restrict to specific servers/channels
    allowed_guild_ids: ["123456789012345678"]

Connecting Slack

# ~/.hermes/.env
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...    # for Socket Mode
gateway:
  slack:
    enabled: true

What’s Actually Unified Across Platforms

The gateway centralizes several things so you don’t reimplement them per platform:

  • Session management: a conversation on Telegram and a conversation on Slack draw from the same underlying memory system (Module 4), the agent’s persistent knowledge of you doesn’t fragment by platform.
  • Cron delivery: a scheduled task (next lesson) can deliver its result to whichever platform makes sense, without separate scheduling logic per adapter.
  • Media handling: attachments and voice transcription are handled once, at the gateway level, rather than per platform.
  • Live typing status: the gateway shows a “typing…” indicator on platforms that support it (Telegram, Discord, Signal) or an “is thinking…” status (Slack), so users get the same responsiveness cue regardless of which platform they’re on.

What is not forced to be identical: tool availability. You can scope a different toolset per platform, the same platform_toolsets mechanism from Lesson 7.3, applied per adapter, so a public Discord server and a private Telegram chat with yourself can have very different capability levels while sharing the same underlying agent.

Checking Gateway Health

hermes gateway status

reports each connected adapter independently. Because platforms connect through separate adapters sharing one gateway process, one platform’s credentials expiring or connection dropping doesn’t take down the others, but it does mean you check status per platform, not just “is the gateway running.”

Exercise: connect one messaging platform (Telegram is the fastest to set up, via @BotFather) to your Hermes gateway, and send it a message that requires a tool call, something that exercises the same tool-calling loop from Module 3. Then run hermes gateway status and confirm it reports that platform as healthy.

Knowledge Check

3 questions to test your understanding

1 The gateway is described as a single background process that connects to all your configured platforms. What does that architecture mean for how sessions and tool configuration behave across Telegram, Discord, and Slack simultaneously?

2 What does 'per-platform tool configuration, shared across adapters' actually let you do that a single global tool list would not?

3 Your Slack integration stops responding but Telegram and Discord still work fine. What should you check first, based on how the gateway is architected?

Go further with expert guidance

Ready to build production AI?
Talk to our R&D team.

These courses give you the foundation. Our embedded AI teams take you from prototype to production in 30–90 days, with your team, your codebase, your goals. Book a free strategy call to see how we can accelerate your AI initiative.

30 minutes · No obligation · Expert AI engineers, not sales reps

AI Architecture Review

Audit your current stack and identify high-impact improvements

Project Review

Get expert feedback on your AI implementation and codebase

Team Mentoring

Upskill your engineers with hands-on AI coaching sessions

AI Strategy

Define your AI roadmap, prioritization, and implementation plan