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
| channel | transport | auth |
|---|---|---|
| CLI | stdin/stdout | none |
| Telegram | Bot API (long polling) | bot token |
| Discord | Gateway WebSocket | bot token |
| Slack | Events API | app + bot token |
| Matrix | homeserver sync | access token |
| iMessage | AppleScript bridge | macOS only |
| Business API | API credentials | |
| Webhook | HTTP POST | gateway 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"
}
}