加入我们的 Telegram 社群 (clawdbotCN) 学习分享和了解更多 →
en
Channels
Telegram

Telegram Configuration

Telegram is typically the fastest channel to set up, integrating through the grammY library.

Quick Start

1. Create a Bot

  1. Find @BotFather (opens in a new tab) in Telegram
  2. Send the /newbot command
  3. Follow prompts to set Bot name and username
  4. Copy the Bot Token

2. Configure

{
  channels: {
    telegram: {
      enabled: true,
      botToken: "YOUR_BOT_TOKEN"
    }
  }
}

Or use environment variable:

export TELEGRAM_BOT_TOKEN="YOUR_BOT_TOKEN"

3. Start

clawdbot gateway run

Access Control

DM Policy

{
  channels: {
    telegram: {
      // Pairing mode (default) - new users need pairing code
      dmPolicy: "pairing",
 
      // Allowlist mode
      dmPolicy: "allowlist",
      allowFrom: ["123456789", "987654321"],
 
      // Open mode
      dmPolicy: "open"
    }
  }
}

Group Policy

{
  channels: {
    telegram: {
      // Default requires @mention
      groups: {
        "*": {
          requireMention: true
        }
      },
 
      // Specific group configuration
      groups: {
        "-1001234567890": {
          requireMention: false  // Always respond
        }
      }
    }
  }
}

Features

Streaming

Supports real-time streaming responses:

{
  channels: {
    telegram: {
      streamMode: "partial",  // Periodic message updates
      textChunkLimit: 4000    // Max characters per message
    }
  }
}

Inline Buttons

Supports interactive inline buttons:

{
  channels: {
    telegram: {
      inlineButtons: true
    }
  }
}

Voice Notes

Supports sending and receiving voice messages.

Draft Streaming

Enable draft streaming in private chats:

{
  channels: {
    telegram: {
      draftStreaming: true  // Private chats only
    }
  }
}

Reply Mode

{
  channels: {
    telegram: {
      replyToMode: "first",  // Reply to first message only
      // or
      replyToMode: "all",    // Reply to all messages
      // or
      replyToMode: "off"     // Don't use reply feature
    }
  }
}

Forum Topic Support

Support forum topics in supergroups:

{
  channels: {
    telegram: {
      groups: {
        "-1001234567890": {
          // Isolate conversations by topic
          forumTopics: true
        }
      }
    }
  }
}

Privacy Mode

To receive all group messages:

  1. Disable privacy mode in @BotFather, or
  2. Add the Bot as a group administrator

Full Configuration Example

{
  channels: {
    telegram: {
      enabled: true,
      botToken: "YOUR_BOT_TOKEN",
 
      dmPolicy: "pairing",
      groupPolicy: "open",
 
      streamMode: "partial",
      textChunkLimit: 4000,
 
      replyToMode: "first",
      typingIndicator: true,
      inlineButtons: true,
 
      groups: {
        "*": {
          requireMention: true,
          historyCount: 50
        }
      }
    }
  }
}

Next Steps