Skip to content

Platform Adapters

源码版本v2026.7.20

Responsibility

Each platform (Telegram, Discord, Slack, Signal, WhatsApp, WeChat, QQ...) has an adapter that translates native platform events into the unified MessageEvent and translates unified send actions back into platform API calls. Adapters inherit BasePlatformAdapter and implement a few abstract methods. Adapters can come from the built-in gateway/platforms/ or from plugins in plugins/platforms/; both register via PlatformRegistry.

Key Files

Data Flow

  1. At startup GatewayRunner (gateway/run.py:3029) brings up adapters via _start_one_profile_adapter:9389.
  2. Adapters are looked up by name from PlatformRegistry (gateway/platform_registry.py:162), supporting deferred loading (a cheap placeholder first; real import only when used).
  3. Adapters listen for platform events, translate them into MessageEvent:1759s, and hand them to _handle_message:9947.
  4. When the agent produces streaming output, the adapter delivers it back to the platform via the unified interface (send:3008 / send_draft); media goes through CachedMedia:1638.
  5. Platform differences (message length, rich text, image limits) are absorbed inside the adapter; the gateway core is unaware.

Summary

Adapter = a translator between "platform dialect" and "unified event". Adding a platform only requires subclassing BasePlatformAdapter, implementing a few abstract methods, and registering — see gateway/platforms/ADDING_A_PLATFORM.md. Telegram/Discord/Slack go through the plugin path and are treated the same as built-in adapters.

Unofficial community learning site. Content based on the MIT-licensed NousResearch/hermes-agent source.