Telegram 是最快配置的频道 —— 大约 90 秒。Bot 默认是私密的,除非你分享用户名,否则没人能找到你的 bot。

创建 bot

  1. 打开 Telegram,搜索 @BotFather,开始聊天。
  2. /newbot
  3. 显示名(例如 "Mira Agent")
  4. _bot 结尾的用户名(必须全球唯一,例如 mira_agent_bot)
  5. BotFather 会发一个像 123456789:ABCdef… 这样的 token。存好。

和你的 bot 开一个聊天

BotFather 的消息里有 t.me/<username>。点它,和你的 bot 开一个 DM,按 Start。bot 在 Sentō 跑起来之前都会保持安静 —— 这只是为了让聊天存在,这样之后智能体能给你发 DM。

运行 sento init

npx sentoagent init

选 Telegram,粘贴 token。不需要 server ID —— Telegram bot 按 chat 工作,通过 chat_id

访问控制

~/.claude/channels/telegram/.env 存 token。访问规则在 ~/.claude/channels/telegram/access.json 里:

{
  "dmPolicy": "allowlist",
  "allowFrom": ["123456789"],
  "groups": {
    "-1001234567890": { "requireMention": true, "allowFrom": [] }
  }
}
  • DM 的 allowFrom 存 Telegram 用户 ID(数字)。
  • groups 的键是 chat ID(群组是负数,以 -100 开头)。
  • 群里 requireMention: true 意味着 bot 只在被 @ 其用户名时响应。

找一个 chat 或 user ID

最简单:给 bot 发条消息,然后查:

curl "https://api.telegram.org/bot<TOKEN>/getUpdates"

每条消息的 payload 都包含 message.chat.idmessage.from.id

为什么 Telegram 快

  • 没有 intents、scope 或 developer portal。
  • Bot 开箱即用支持 Markdown 格式。
  • long-polling(通过 getUpdates)不需要 webhook URL,所以 Telegram 在家庭 IP 上没有端口转发也能跑。