Skip to main content
Channels are WASM components that handle communication with external messaging platforms (Telegram, WhatsApp, Slack, etc.). They run in a sandboxed environment and communicate with the host via the WIT interface.

Overview

A channel:
  • Receives messages from a messaging platform (webhook or polling)
  • Emits messages to the agent for processing
  • Sends agent responses back to the platform
  • Runs isolated with explicit capabilities

Directory Structure

After building, deploy to:

Step 1: Create Cargo.toml

Step 2: Implement the Channel

Required Imports

Implement the Guest Trait

Critical Pattern: Metadata Flow

The most important pattern: Store routing info in metadata so responses can be delivered.

Step 3: Create Capabilities File

Create my-channel.capabilities.json:

Building and Deploying

Build

Install

Enable

Host Functions Available

Logging

Time

Workspace

HTTP Requests

Emit Message to Agent

Common Patterns

Webhook Secret Validation

The host validates automatically, but check req.secret_validated:

Polling with Offset Tracking

Bot Message Filtering

Skip bot messages to prevent loops:

Status Message Filtering

Skip status updates:

Testing

Add tests to lib.rs:

Troubleshooting

”byte index N is not a char boundary”

Never slice strings by byte index! Use character-aware truncation:

Credential Placeholders Not Replaced

  1. Check the secret name matches (lowercase with underscores)
  2. Verify the secret is in allowed_names in capabilities
  3. Check logs for “unresolved placeholders” warnings

Messages Not Routing to Responses

Ensure on_respond uses the ORIGINAL message’s metadata:

Supply Chain Security

Do not commit compiled WASM binaries. They are a supply chain risk — the binary in a PR may not match the source.
  • Build channels from source: cargo build
  • The built binary is in .gitignore
  • CI should run cargo build to produce releases

Examples

Check the bundled channel:
  • channels-src/telegram/ - Full Telegram implementation with polling and webhooks

Next Steps