令牌、白名单与 requireMention
结合令牌、allowFrom 白名单和群组 requireMention,控制哪些人可以联系您的助手。
令牌、白名单与 requireMention 是 CoddyKit 上的免费 OpenClaw Academy 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 OpenClaw Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 OpenClaw Academy 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Three Tools, One Goal
To control who reaches your assistant, you combine three things: tokens, allowlists, and required mentions. Together they form your front line. 🔐
What Tokens Do
A token is a secret that proves a channel or client is allowed to connect to your Gateway. Keep it private, like a house key.
The allowFrom Allowlist
The allowFrom key lists exactly which senders may message OpenClaw on a channel. Anyone not listed is simply ignored.
Allowlist In Config
You set allowFrom inside your channel block. Here a WhatsApp channel only accepts one number, shown in JSON5 config.
{
channels: {
whatsapp: {
allowFrom: ["+15555550123"]
}
}
}Where It Lives
That config sits in ~/.openclaw/openclaw.json. Edit it, and OpenClaw enforces your allowlist the next time it handles messages.
requireMention In Groups
For group chats, requireMention tells OpenClaw to stay quiet unless it is explicitly mentioned, so it never reacts to every message.
requireMention Example
Apply requireMention to all groups with a wildcard so the assistant only speaks when called by name.
{
channels: {
whatsapp: {
groups: { "*": { requireMention: true } }
}
}
}Mention Patterns
Define how to call it with mentionPatterns, like @openclaw. Only messages matching a pattern count as a real mention.
{
messages: {
groupChat: { mentionPatterns: ["@openclaw"] }
}
}Layer Them Together
Each control closes a different gap. Layering tokens, allowFrom, and requireMention is far safer than relying on any single one.
Tokens For Channels
Tokens authenticate the channel connection itself, while allowFrom decides which people behind that channel are trusted to send commands.
Start Strict
A safe habit is to start strict: empty allowlists, mentions required, then add only the senders you truly need over time.
Quick Check
Match each control to what it actually limits.
Recap
Use tokens to authenticate channels, allowFrom to allow senders, and requireMention plus mentionPatterns to stay quiet until called. ✅
常见问题解答
「令牌、白名单与 requireMention」课时是免费的吗?
是的 — 「令牌、白名单与 requireMention」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 OpenClaw Academy 课程的其余内容,请升级到 CoddyKit PRO。 OpenClaw Academy 课程共包含 4 节课。
「令牌、白名单与 requireMention」这节课中我会学到什么?
结合令牌、allowFrom 白名单和群组 requireMention,控制哪些人可以联系您的助手。 你通过在浏览器中直接运行的动手代码来练习 OpenClaw Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 OpenClaw Academy 需要有经验吗?
无需任何先前经验。CoddyKit 上的 OpenClaw Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。
「令牌、白名单与 requireMention」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 OpenClaw Academy 课中编写并运行代码吗?
能。每节 OpenClaw Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 为什么防护机制很重要
- 令牌、白名单与 requireMention
- Gateway 安全文档
- 通过 SSH 和 Tailscale 进行远程访问