Interface ChannelAdapter

All Known Subinterfaces:
StreamingChannelAdapter
All Known Implementing Classes:
CliChannel, DiscordChannel, EmailChannel, SlackChannel, TelegramAdapter, WhatsAppChannel

public interface ChannelAdapter
Core contract for messaging channel integrations.

Each channel (Telegram, Discord, Slack, etc.) implements this interface and registers via SPI (META-INF/services/com.tnsai.channels.api.ChannelAdapter).

Lifecycle: start(com.tnsai.channels.api.ChannelContext) is called once by the ChannelRegistry with a ChannelContext for delivering inbound messages. stop() tears down the connection.

  • Method Summary

    Modifier and Type
    Method
    Description
    Declares what this channel supports.
    Human-readable display name.
    id()
    Unique identifier for this channel (e.g.
    boolean
    Whether the adapter is currently connected and operational.
    void
    Send a response back through this channel.
    void
    Start listening for inbound messages.
    void
    Stop listening and release resources.
  • Method Details

    • id

      String id()
      Unique identifier for this channel (e.g. "telegram", "discord", "slack").
    • displayName

      String displayName()
      Human-readable display name.
    • capabilities

      ChannelCapabilities capabilities()
      Declares what this channel supports.
    • start

      void start(ChannelContext context)
      Start listening for inbound messages. The adapter should call ChannelContext.onMessage(com.tnsai.channels.api.UnifiedMessage) when a message arrives.
      Parameters:
      context - callback interface for delivering events to the gateway
    • stop

      void stop()
      Stop listening and release resources.
    • send

      void send(UnifiedResponse response)
      Send a response back through this channel.
      Parameters:
      response - the unified response to deliver
    • isRunning

      boolean isRunning()
      Whether the adapter is currently connected and operational.