Channel trait defines the interface for all messaging platforms in ZeroClaw. Implement this trait to integrate new communication channels like Slack, Discord, Telegram, or custom protocols.
Trait Definition
Required Methods
name
Return the human-readable channel name.
&str
Stable lowercase identifier (e.g., βcliβ, βdiscordβ, βslackβ)
send
Send a message through this channel.
&SendMessage
required
anyhow::Result<()>
Success or error
listen
Start listening for incoming messages. This is a long-running async task.
tokio::sync::mpsc::Sender<ChannelMessage>
required
Channel sender to forward received messages to the agent
anyhow::Result<()>
Returns when listener stops or encounters error
Optional Methods with Defaults
health_check
Check if the channel is healthy and reachable.
bool
Returns
true if channel is operationaltrue.
start_typing
Signal that the bot is processing a response (typing indicator).
&str
required
User or channel to show typing indicator to
stop_typing
Stop any active typing indicator.
&str
required
User or channel to stop typing indicator for
supports_draft_updates
Whether this channel supports progressive message updates via draft edits.
bool
Returns
true if draft updates are supportedfalse.
send_draft
Send an initial draft message for progressive updates.
&SendMessage
required
Initial draft message content
anyhow::Result<Option<String>>
Platform-specific message ID for later edits, or
None if not supportedOk(None).
update_draft
Update a previously sent draft message with new accumulated content.
&str
required
Message recipient
&str
required
Platform message ID from
send_draft&str
required
Updated message content
anyhow::Result<Option<String>>
Ok(None)to keep current draft message IDOk(Some(new_id))when a continuation message was created (e.g., after hitting edit-count cap)
Ok(None).
finalize_draft
Finalize a draft with the complete response (apply formatting).
&str
required
Message recipient
&str
required
Platform message ID
&str
required
Final message content
cancel_draft
Cancel and remove a previously sent draft message.
&str
required
Message recipient
&str
required
Platform message ID to cancel
send_approval_prompt
Send an interactive approval prompt for tool execution.
&str
required
User to prompt
&str
required
Unique request identifier
&str
required
Name of tool requiring approval
&serde_json::Value
required
Tool arguments to display
Option<String>
Thread identifier for threaded replies
/approve-allow and /approve-deny commands.
add_reaction
Add a reaction (emoji) to a message.
&str
required
Platform channel/conversation identifier
&str
required
Platform-scoped message identifier
&str
required
Unicode emoji (e.g., βπβ, ββ
β)
remove_reaction
Remove a reaction previously added by this bot.
&str
required
Platform channel identifier
&str
required
Platform message identifier
&str
required
Unicode emoji to remove
Helper Types
SendMessage
ChannelMessage
Implementation Example
Hereβs a complete CLI channel implementation:Factory Registration
Register your channel in the factory:Best Practices
Thread Safety: The
listen method runs in a long-lived async task. Ensure your implementation handles reconnection and graceful shutdown.Related
- Provider Trait - Implement LLM providers
- Tool Trait - Implement tools
- Configuration Reference - Configure channels in config.toml