Skip to main content

Channel Setup

OpenFang supports 40 messaging platforms through channel adapters. Each adapter enables agents to receive messages and respond across different communication channels.

Quick Setup

1

List available channels

openfang channel list
Shows all 40 channels with their status (enabled/disabled/not-configured).
2

Run setup wizard

openfang channel setup telegram
Interactive wizard guides you through:
  • Creating bot tokens
  • Configuring credentials
  • Setting permissions
  • Testing the connection
3

Enable the channel

openfang channel enable telegram
4

Test it

openfang channel test telegram
Sends a test message to verify the connection.

Platform-Specific Guides

Telegram

1

Create a bot

  1. Message @BotFather on Telegram
  2. Send /newbot
  3. Follow prompts to choose name and username
  4. Copy the bot token (format: 123456:ABC-DEF...)
2

Configure OpenFang

export TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
openfang channel setup telegram
Or edit ~/.openfang/config.toml:
[channels.telegram]
enabled = true
bot_token_env = "TELEGRAM_BOT_TOKEN"
3

Start chatting

Find your bot on Telegram and send /start. Your agent will respond!

Discord

1

Create a Discord bot

  1. Go to Discord Developer Portal
  2. Click “New Application”
  3. Navigate to “Bot” tab
  4. Click “Add Bot”
  5. Copy the bot token
  6. Enable “Message Content Intent” under Privileged Gateway Intents
2

Invite bot to server

  1. Go to “OAuth2” → “URL Generator”
  2. Select scopes: bot, applications.commands
  3. Select permissions: Send Messages, Read Message History
  4. Copy and visit the generated URL
3

Configure OpenFang

export DISCORD_BOT_TOKEN=your-token-here
openfang channel setup discord

Slack

1

Create a Slack app

  1. Go to api.slack.com/apps
  2. Click “Create New App” → “From scratch”
  3. Choose app name and workspace
2

Configure permissions

Under “OAuth & Permissions”, add Bot Token Scopes:
  • chat:write
  • channels:history
  • groups:history
  • im:history
  • mpim:history
3

Install to workspace

Click “Install to Workspace” and authorize. Copy the “Bot User OAuth Token” (starts with xoxb-).
4

Configure OpenFang

export SLACK_BOT_TOKEN=xoxb-...
openfang channel setup slack

WhatsApp

WhatsApp requires the official WhatsApp Business API. See packages/whatsapp-gateway for setup instructions.
1

Deploy WhatsApp gateway

cd packages/whatsapp-gateway
npm install
npm start
2

Configure OpenFang

[channels.whatsapp]
enabled = true
gateway_url = "http://localhost:3000"

Email (IMAP/SMTP)

1

Get credentials

For Gmail:
  1. Enable 2FA on your Google account
  2. Generate an App Password at myaccount.google.com/apppasswords
  3. Use this password (not your regular Gmail password)
2

Configure OpenFang

[channels.email]
enabled = true
imap_host = "imap.gmail.com"
imap_port = 993
smtp_host = "smtp.gmail.com"
smtp_port = 587
username = "[email protected]"
password_env = "EMAIL_PASSWORD"

Channel Configuration

Per-Channel Overrides

Customize agent behavior per channel:
[channels.telegram]
enabled = true
bot_token_env = "TELEGRAM_BOT_TOKEN"

[channels.telegram.overrides]
model_provider = "groq"  # Use faster/cheaper model for Telegram
model = "llama-3-70b"
output_format = "markdown"  # Format messages as Markdown
rate_limit = {messages = 10, window = 60}  # 10 msgs per minute

[channels.telegram.policies]
dm_policy = "whitelist"  # Only respond to whitelisted users
allowed_users = ["@alice", "@bob"]
group_policy = "disabled"  # Don't respond in groups

Output Formatting

Choose how agent responses are formatted:
[channels.telegram.overrides]
output_format = "telegram_html"  # TelegramHTML (bold, italic, links)

[channels.slack.overrides]
output_format = "slack_mrkdwn"   # Slack Markdown flavor

[channels.discord.overrides]
output_format = "markdown"       # Standard Markdown

[channels.sms.overrides]
output_format = "plain"          # Plain text only

Testing Channels

After setup, test each channel:
# Test individual channel
openfang channel test telegram

# Test all enabled channels
openfang channel test --all

# View channel logs
tail -f ~/.openfang/logs/channels/telegram.log

Troubleshooting

  1. Check channel is enabled: openfang channel list
  2. Verify token is correct: openfang config show
  3. Check logs: tail ~/.openfang/logs/channels/*.log
  4. Ensure agent is running: openfang agent list
Reduce rate_limit in channel config:
[channels.telegram.overrides]
rate_limit = {messages = 5, window = 60}
Verify bot has required scopes/permissions in the platform’s developer portal.
Ensure the WhatsApp gateway is running and accessible:
curl http://localhost:3000/health

Channel Security

DM/Group Policies

Control where agents respond:
[channels.telegram.policies]
dm_policy = "whitelist"          # Only respond to allowed users in DMs
allowed_users = ["@alice"]
group_policy = "opt-in"          # Only respond when mentioned in groups
Options:
  • allow_all - Respond to everyone
  • whitelist - Only respond to allowed users
  • opt-in - Require explicit mention/activation
  • disabled - Don’t respond at all

Rate Limiting

Per-user rate limits prevent abuse:
[channels.telegram.overrides]
rate_limit = {
  messages = 10,   # Max messages
  window = 60      # Per 60 seconds
}

Next Steps

Channel Configuration

Complete channel configuration reference

Agent Setup

Configure agents to work with channels

Build docs developers (and LLMs) love