``` Claude 代码:频道 ```
Push events into a running session with channels

原始链接: https://code.claude.com/docs/en/channels

## Claude 代码频道:摘要 Claude 代码现在支持“频道”,这是一个研究预览功能,允许来自 Telegram 和 Discord 等平台的消息、警报、Webhook 推送到正在运行的会话中。这使得 Claude 即使在您未主动使用终端时也能对事件做出反应。 频道作为 MCP 服务器以插件形式安装,需要 Claude 代码 v2.1.80+ 和 claude.ai 登录。团队/企业组织需要明确的管理员启用。设置包括安装所需的插件(Telegram、Discord 或自定义构建),使用 API 令牌进行配置,并使用 `--channels` 标志重启 Claude 代码。 安全性通过发送者允许列表进行管理,通过代码交换“配对”您的帐户与机器人来启动。团队/企业计划的管理员控制整个频道的可用性。 目前,仅支持来自 `claude-plugins-official` 市场的插件,但开发者可以使用特定标志测试自定义频道。频道专为自动化和远程交互而设计,补充了钩子和计划任务等功能。鼓励通过 Claude 代码 GitHub 仓库提供反馈。

## Claude 代码频道:摘要 Anthropic 的 Claude 代码现在提供“频道”功能,允许通过网络钩子与外部服务集成——目前主要关注 Telegram,因为它拥有庞大的用户群(10 亿月活跃用户),超过 Slack 和 Teams。 讨论强调用户对基于事件自动化 Claude 代码的兴奋,这类似于之前使用 nanoclaw 等工具实现的功能。一个关键用例似乎是代理之间的通信,但将 Claude 可靠地连接到消息系统的挑战仍然存在。 用户也注意到 Claude 专注于本地“会话”模型进行集成,这可能为以后更可控的生态系统铺平道路。有人对 Telegram 的机器人问题表示担忧,一些用户报告了类似于 Gemini 中发现的标签编辑错误。一些人认为此次发布是对开源项目 OpenClaw 及其主要开发人员被 OpenAI 收购的回应。
相关文章

原文
Skip to main content
Channels are in research preview and require Claude Code v2.1.80 or later. They require claude.ai login. Console and API key authentication is not supported. Team and Enterprise organizations must explicitly enable them.
A channel is an MCP server that pushes events into your running Claude Code session, so Claude can react to things that happen while you’re not at the terminal. Channels can be two-way: Claude reads the event and replies back through the same channel, like a chat bridge. Events only arrive while the session is open, so for an always-on setup you run Claude in a background process or persistent terminal. You install a channel as a plugin and configure it with your own credentials. Telegram and Discord are included in the research preview. When Claude replies through a channel, you see the inbound message in your terminal but not the reply text. The terminal shows the tool call and a confirmation (like “sent”), and the actual reply appears on the other platform. This page covers: To build your own channel, see the Channels reference.

Supported channels

Each supported channel is a plugin that requires Bun. For a hands-on demo of the plugin flow before connecting a real platform, try the fakechat quickstart.
:first-child:not(p)]:mt-0 [&>:first-child:not(p)_img]:mt-0" data-component-part="tab-content">View the full Telegram plugin source.
1

Create a Telegram bot

Open BotFather in Telegram and send /newbot. Give it a display name and a unique username ending in bot. Copy the token BotFather returns.
2

Install the plugin

In Claude Code, run:
/plugin install telegram@claude-plugins-official
3

Configure your token

Run the configure command with the token from BotFather:
/telegram:configure 
This saves it to .claude/channels/telegram/.env in your project. You can also set TELEGRAM_BOT_TOKEN in your shell environment before launching Claude Code.
4

Restart with channels enabled

Exit Claude Code and restart with the channel flag. This starts the Telegram plugin, which begins polling for messages from your bot:
claude --channels plugin:telegram@claude-plugins-official
5

Pair your account

Open Telegram and send any message to your bot. The bot replies with a pairing code.
If your bot doesn’t respond, make sure Claude Code is running with --channels from the previous step. The bot can only reply while the channel is active.
Back in Claude Code, run:
/telegram:access pair 
Then lock down access so only your account can send messages:
/telegram:access policy allowlist
:first-child:not(p)]:mt-0 [&>:first-child:not(p)_img]:mt-0 hidden" data-component-part="tab-content">View the full Discord plugin source.
1

Create a Discord bot

Go to the Discord Developer Portal, click New Application, and name it. In the Bot section, create a username, then click Reset Token and copy the token.
2

Enable Message Content Intent

In your bot’s settings, scroll to Privileged Gateway Intents and enable Message Content Intent.
3

Invite the bot to your server

Go to OAuth2 > URL Generator. Select the bot scope and enable these permissions:
  • View Channels
  • Send Messages
  • Send Messages in Threads
  • Read Message History
  • Attach Files
  • Add Reactions
Open the generated URL to add the bot to your server.
4

Install the plugin

In Claude Code, run:
/plugin install discord@claude-plugins-official
5

Configure your token

Run the configure command with the bot token you copied:
/discord:configure 
This saves it to .claude/channels/discord/.env in your project. You can also set DISCORD_BOT_TOKEN in your shell environment before launching Claude Code.
6

Restart with channels enabled

Exit Claude Code and restart with the channel flag. This connects the Discord plugin so your bot can receive and respond to messages:
claude --channels plugin:discord@claude-plugins-official
7

Pair your account

DM your bot on Discord. The bot replies with a pairing code.
If your bot doesn’t respond, make sure Claude Code is running with --channels from the previous step. The bot can only reply while the channel is active.
Back in Claude Code, run:
/discord:access pair 
Then lock down access so only your account can send messages:
/discord:access policy allowlist
You can also build your own channel for systems that don’t have a plugin yet.

Quickstart

Fakechat is an officially supported demo channel that runs a chat UI on localhost, with nothing to authenticate and no external service to configure. Once you install and enable fakechat, you can type in the browser and the message arrives in your Claude Code session. Claude replies, and the reply shows up back in the browser. After you’ve tested the fakechat interface, try out Telegram or Discord. To try the fakechat demo, you’ll need:
1

Install the fakechat channel plugin

Start a Claude Code session and run the install command:
/plugin install fakechat@claude-plugins-official
Fakechat is in the claude-plugins-official marketplace, which is added automatically for most setups. If you don’t have it, run /plugin marketplace add anthropics/claude-plugins-official first.
2

Restart with the channel enabled

Exit Claude Code, then restart with --channels and pass the fakechat plugin you installed:
claude --channels plugin:fakechat@claude-plugins-official
The fakechat server starts automatically.
You can pass several plugins to --channels, space-separated.
3

Push a message in

Open the fakechat UI at http://localhost:8787 and type a message:
hey, what's in my working directory?
The message arrives in your Claude Code session as a event. Claude reads it, does the work, and calls fakechat’s reply tool. The answer shows up in the chat UI.
If Claude hits a permission prompt while you’re away from the terminal, the session pauses until you approve locally. For unattended use, --dangerously-skip-permissions bypasses prompts, but only use it in environments you trust.

Security

Every approved channel plugin maintains a sender allowlist: only IDs you’ve added can push messages, and everyone else is silently dropped. Telegram and Discord bootstrap the list by pairing:
  1. Find your bot in Telegram or Discord and send it any message
  2. The bot replies with a pairing code
  3. In your Claude Code session, approve the code when prompted
  4. Your sender ID is added to the allowlist
On top of that, you control which servers are enabled each session with --channels, and on Team and Enterprise plans your organization controls availability with channelsEnabled. Being in .mcp.json isn’t enough to push messages: a server also has to be named in --channels.

Enterprise controls

Channels are controlled by the channelsEnabled setting in managed settings.
Plan typeDefault behavior
Pro / Max, no organizationChannels available; users opt in per session with --channels
Team / EnterpriseChannels disabled until an admin explicitly enables them

Enable channels for your organization

Admins can enable channels from claude.ai → Admin settings → Claude Code → Channels, or by setting channelsEnabled to true in managed settings. Once enabled, users in your organization can use --channels to opt channel servers into individual sessions. If the setting is disabled or unset, the MCP server still connects and its tools work, but channel messages won’t arrive. A startup warning tells the user to have an admin enable the setting.

Research preview

Channels are a research preview feature. Availability is rolling out gradually, and the --channels flag syntax and protocol contract may change based on feedback. During the preview, --channels only accepts plugins from an Anthropic-maintained allowlist. The channel plugins in claude-plugins-official are the approved set. If you pass something that isn’t, Claude Code starts normally but the channel doesn’t register, and the startup notice tells you why. To test a channel you’re building, use --dangerously-load-development-channels. See Test during the research preview for information about testing custom channels that you build. Report issues or feedback on the Claude Code GitHub repository.

Next steps

Once you have a channel running, explore these related features:
联系我们 contact @ memedata.com