BaihuBaihu
Channels

channels overview

7 chat channels with a pluggable trait system

how channels work

every channel implements the Channel trait:

#[async_trait]
pub trait Channel: Send + Sync {
    async fn start(&self) -> Result<()>;
    async fn stop(&self) -> Result<()>;
    fn name(&self) -> &str;
}

all channels run simultaneously through the daemon's JoinSet. each channel receives messages, routes them through the agent, and sends responses back.

available channels

channeltransportauth
CLIstdin/stdoutnone
TelegramBot API (long polling)bot token
DiscordGateway WebSocketbot token
SlackEvents APIapp + bot token
Matrixhomeserver syncaccess token
iMessageAppleScript bridgemacOS only
WhatsAppBusiness APIAPI credentials
WebhookHTTP POSTgateway pairing

security

each channel has an allowlist for authorized users/groups:

  • empty list = deny all (safe default)
  • "*" = allow all (explicit opt-in)
  • specific IDs = exact match

implementing a custom channel

use baihu::channels::Channel;

struct MyChannel;

#[async_trait]
impl Channel for MyChannel {
    async fn start(&self) -> Result<()> {
        // connect and listen for messages
    }

    async fn stop(&self) -> Result<()> {
        // graceful disconnect
    }

    fn name(&self) -> &str {
        "my-channel"
    }
}

On this page