Channels connect OpenFang agents to external messaging platforms like Telegram, Discord, Slack, and more. All channel commands are under the openfang channel namespace.
$ openfang channel setup telegram ═══════════════════════════════════════════════════════════════ Telegram Bot Setup ═══════════════════════════════════════════════════════════════ Step 1: Create a bot 1. Open Telegram and search for @BotFather 2. Send /newbot and follow the prompts 3. Copy the bot token (format: 123456:ABC-DEF...) Step 2: Get your chat ID 1. Send a message to your bot 2. Visit: https://api.telegram.org/bot<TOKEN>/getUpdates 3. Look for "chat":{"id":<CHAT_ID>} ─────────────────────────────────────────────────────────────── Paste your Telegram bot token: 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz Enter your chat ID: 987654321 [ok] Saved TELEGRAM_BOT_TOKEN to ~/.openfang/.env [ok] Added telegram configuration to config.toml Restart the daemon to activate: openfang stop && openfang start
$ openfang channel setup discord ═══════════════════════════════════════════════════════════════ Discord Bot Setup ═══════════════════════════════════════════════════════════════ Step 1: Create a Discord application 1. Go to: https://discord.com/developers/applications 2. Click "New Application" 3. Go to "Bot" → "Add Bot" 4. Copy the bot token Step 2: Enable intents 1. In Bot settings, enable: - MESSAGE CONTENT INTENT - SERVER MEMBERS INTENT 2. Click "Save Changes" Step 3: Invite bot to your server 1. Go to "OAuth2" → "URL Generator" 2. Select scopes: bot 3. Select permissions: Send Messages, Read Message History 4. Copy and visit the generated URL ─────────────────────────────────────────────────────────────── Paste your Discord bot token: MTIzNDU2Nzg5MDEyMzQ1Njc4OTAuGhIjKl.MnOpQrStUvWxYzAbCdEfGhIjKlMnOpQr Enter your server (guild) ID: 123456789012345678 Enter the channel ID for bot messages: 987654321098765432 [ok] Saved DISCORD_BOT_TOKEN to ~/.openfang/.env [ok] Added discord configuration to config.toml Restart the daemon to activate: openfang stop && openfang start
$ openfang channel setup slack ═══════════════════════════════════════════════════════════════ Slack App Setup ═══════════════════════════════════════════════════════════════ Step 1: Create a Slack app 1. Go to: https://api.slack.com/apps 2. Click "Create New App" → "From scratch" 3. Name your app and select a workspace Step 2: Add bot token scopes 1. Go to "OAuth & Permissions" 2. Add scopes: - chat:write - chat:write.public - channels:history - channels:read 3. Click "Install to Workspace" 4. Copy the "Bot User OAuth Token" (starts with xoxb-) Step 3: Get channel ID 1. Right-click a channel → View channel details 2. Copy the channel ID from the bottom ─────────────────────────────────────────────────────────────── Paste your Slack bot token: xoxb-1234567890-1234567890123-abcdefghijklmnopqrstuvwx Enter the channel ID: C01ABC23DEF [ok] Saved SLACK_BOT_TOKEN to ~/.openfang/.env [ok] Added slack configuration to config.toml Restart the daemon to activate: openfang stop && openfang start
$ openfang channel setup whatsapp ═══════════════════════════════════════════════════════════════ WhatsApp Business API Setup ═══════════════════════════════════════════════════════════════ Requirements: - WhatsApp Business API account - API provider (Twilio, MessageBird, or Vonage) For Twilio: 1. Go to: https://console.twilio.com/ 2. Get Account SID and Auth Token 3. Set up a WhatsApp sender ─────────────────────────────────────────────────────────────── Provider (twilio/messagebird/vonage): twilio Account SID: AC1234567890abcdef1234567890abcdef Auth Token: 1234567890abcdef1234567890abcdef WhatsApp number (with +country code): +14155238886 [ok] Saved WHATSAPP_ACCOUNT_SID and WHATSAPP_AUTH_TOKEN to ~/.openfang/.env [ok] Added whatsapp configuration to config.toml Restart the daemon to activate: openfang stop && openfang start
$ openfang channel test telegram Testing channel: telegram [ok] Connected to Telegram API [ok] Sent test message: "Hello from OpenFang! This is a test message." Check your Telegram for the message.
Test Message Content:The test message includes:
Timestamp
OpenFang version
Confirmation that the channel is working
If the test fails, check the daemon logs: openfang logs or ~/.openfang/tui.log
User (Telegram): Hello, can you help me with Python?Agent (via Telegram): Of course! I'm here to help with Python. What would you like to know?User: How do I read a CSV file?Agent: Here's how to read a CSV file in Python: ```python import csv with open('data.csv', 'r') as file: reader = csv.reader(file) for row in reader: print(row)
Would you like me to explain any part of this code?
## Troubleshooting### Channel Not Responding**Check channel status:**```bashopenfang channel list
Verify environment variables:
# Check if token is setecho $TELEGRAM_BOT_TOKEN# Run diagnosticsopenfang doctor