Skip to main content
OpenFang connects to messaging platforms through 40 channel adapters, allowing users to interact with their agents across every major communication platform. Adapters span consumer messaging, enterprise collaboration, social media, community platforms, privacy-focused protocols, and generic webhooks.

Common Features

All adapters share a common foundation:

Graceful Shutdown

Coordinated shutdown via watch channel

Resilient Connections

Exponential backoff on connection failures

Secret Management

Zeroizing strings for secure token handling

Message Splitting

Automatic splitting for platform limits

Flexible Overrides

Per-channel model and prompt customization

Policy Enforcement

DM/group policy control per channel

Rate Limiting

Per-user rate limiting protection

Format Support

Markdown, Telegram HTML, Slack Mrkdwn, plain text

All 40 Channels

Core Platforms (7)

Enterprise (8)

Social Media (8)

Community Platforms (6)

Self-Hosted (1)

Privacy-Focused (3)

Workplace (4)

Notification Services (2)

Integration (1)

Channel Configuration

All channel configurations live in ~/.openfang/config.toml under the [channels] section.

Common Configuration Fields

The environment variable holding the bot/access token. OpenFang reads the token from this env var at startup. All secrets are stored as Zeroizing<String> and wiped from memory on drop.
The agent name (or ID) that receives messages when no specific routing applies.
Optional list of platform user IDs allowed to interact. Empty means allow all.
Optional per-channel behavior overrides. See Channel Overrides section below.

Channel Overrides

Every channel adapter supports ChannelOverrides, which let you customize behavior per channel without modifying the agent manifest.

Override Fields

Output Formats and Policies

Output Formatter

The formatter module converts Markdown output from the LLM into platform-native formats:

DM Policy

Controls how the adapter handles direct messages:

Group Policy

Controls how the adapter handles messages in group chats, channels, and rooms:
Policy enforcement happens in dispatch_message() before the message reaches the agent loop. This means ignored messages consume zero LLM tokens.

Setup Guides

Telegram

1

Create a bot

Open Telegram and message @BotFather. Send /newbot and follow the prompts.
2

Set environment variable

3

Configure in config.toml

4

Restart the daemon

How It Works: Uses long-polling via the getUpdates API with 30-second timeout. Automatically splits responses over 4096 characters. Interactive Setup:

Discord

1

Create a Discord application

Go to Discord Developer Portal and create a new application.
2

Add a bot

Go to the Bot section, click “Add Bot”, and enable Message Content Intent under Privileged Gateway Intents.
3

Invite the bot

Go to OAuth2 > URL Generator, select scope bot and permissions Send Messages + Read Message History. Use the generated URL to invite the bot.
4

Set environment variable

5

Configure in config.toml

How It Works: Connects to Discord Gateway via WebSocket (v10). Handles reconnection, heartbeating, and session resumption automatically.

Slack

1

Create a Slack app

Go to Slack API, click “Create New App” > “From Scratch”.
2

Enable Socket Mode

Go to Settings > Socket Mode, enable it, and generate an App-Level Token with scope connections:write.
3

Add bot scopes

Go to OAuth & Permissions and add: chat:write, app_mentions:read, im:history, im:read, im:write.
4

Install to workspace

Install the app to your workspace and copy the Bot User OAuth Token.
5

Set environment variables

6

Configure in config.toml

How It Works: Uses Socket Mode WebSocket connection. When threading = true, replies are sent to the message’s thread via thread_ts.

WhatsApp

1

Set up Meta Business account

Go to Meta for Developers and create a Business App.
2

Add WhatsApp product

Add the WhatsApp product and set up a test phone number.
3

Get credentials

Copy the Phone Number ID, Permanent Access Token, and choose a Verify Token.
4

Set environment variables

5

Configure in config.toml

6

Set up webhook

In the Meta dashboard, configure webhook URL: https://your-domain.com:8443/webhook/whatsapp with your verify token.
How It Works: Runs an HTTP server to receive webhooks from WhatsApp Cloud API. Handles verification (GET) and message reception (POST).

Matrix

1

Create bot account

Create a bot account on your Matrix homeserver and generate an access token.
2

Set environment variable

3

Configure in config.toml

4

Invite the bot

Invite the bot to the rooms you want it to monitor.
How It Works: Uses Matrix Client-Server API with long-polling /sync. Processes new messages from joined rooms.

Email

1

Create app password

For Gmail, create an App Password.
2

Set environment variable

3

Configure in config.toml

How It Works: Polls IMAP inbox at configured interval. Sends replies via SMTP, preserving subject line threading.

Agent Routing

The AgentRouter determines which agent receives an incoming message:
1

Per-channel default

Each channel config has a default_agent field. Messages from that channel go to that agent.
2

User-agent binding

If a user has been associated with a specific agent, messages from that user route to that agent.
3

Command prefix

Users can switch agents by sending /agent coder in chat. Subsequent messages route to the “coder” agent.
4

Fallback

If no routing applies, messages go to the first available agent.

WebChat (Built-in)

The WebChat UI is embedded in the daemon and requires no configuration:

Real-time Chat

WebSocket-based communication

Streaming Responses

Text deltas arrive as generated

Agent Selection

Switch between running agents

Token Usage Display

Live token and cost tracking

Writing Custom Adapters

To add support for a new messaging platform, implement the ChannelAdapter trait.

The ChannelAdapter Trait

Implementation Steps

1

Define your adapter

Create crates/openfang-channels/src/myplatform.rs:
2

Implement the trait

Use ChannelType::Custom("myplatform".to_string()) for the channel type. Wrap secrets in Zeroizing<String>. Use exponential backoff for connection failures.
3

Register the module

In crates/openfang-channels/src/lib.rs:
4

Wire into the bridge

Add initialization logic in crates/openfang-api/src/channel_bridge.rs.
5

Add config support

Define config struct in openfang-types and add to ChannelsConfig.
6

Add CLI setup wizard

Add case to cmd_channel_setup in crates/openfang-cli/src/main.rs.
Key points for new adapters:
  • Only the 9 most common channels have named ChannelType variants. All others use Custom(String).
  • Wrap secrets in Zeroizing<String> so they are wiped from memory on drop.
  • Accept a watch::Receiver<bool> for coordinated shutdown with the daemon.
  • Use the shared split_message(text, max_len) utility for platforms with message length limits.