# OpenClaw 插件系统使用指南:打造专属的AI工作流
今天咱们来聊聊 OpenClaw 的插件系统。前面说了技能(Skills),这次咱们说说插件(Plugins)。虽然名字听起来差不多,但其实定位完全不同。

## 一、技能和插件到底有什么区别?
这是个好问题!咱们先把这个搞清楚。
**技能(Skills)** 是面向普通用户的扩展方式——你不需要写代码,装上就能用。就像手机里装个 App,点点按钮就搞定了。
**插件(Plugins)** 是面向开发者的扩展方式——它是轻量级的代码模块,可以为 OpenClaw 添加新的命令、工具,甚至扩展 Gateway 的 RPC 能力。如果你想定制一些专属功能,插件才是正确的选择。
| 对比项 | 技能(Skills) | 插件(Plugins) |
|——–|—————|—————-|
| 面向用户 | 普通用户 | 开发者 |
| 难度 | 零门槛 | 需要代码能力 |
| 扩展方式 | 装上就能用 | 需要写代码 |
| 配置方式 | 配置文件 | 代码集成 |
| 更新频率 | 社区贡献 | 官方维护为主 |
## 二、查看已安装的插件
openclaw plugins list
执行这条命令,会列出当前 OpenClaw 里已经加载的所有插件,包括每个插件的名称、版本和状态信息。
## 三、安装官方插件
OpenClaw 的插件通过 npm 包的形式分发,安装非常方便:
# 安装官方插件(示例:语音通话插件)
openclaw plugins install @openclaw/v
# 安装其他官方插件
openclaw plugins install @openclaw/calendar
openclaw plugins install @openclaw/contacts
安装完成后,插件会自动加载,不需要手动重启网关。
## 四、插件的工作原理
插件本质上是一个 Node.js 模块,符合 OpenClaw 的插件接口规范。一个最简单的插件结构如下:
// 插件入口文件 index.js
module.exports = {
name: 'my-plugin',
version: '1.0.0',
// 插件初始化时调用
onLoad(gateway) {
console.log('插件加载了!');
},
// 注册自定义命令
commands: [
{
name: 'hello',
handler: (args) => {
return '你好!我是自定义插件!';
}
}
],
// 注册自定义工具
tools: [
{
name: 'myTool',
description: '我的自定义工具',
execute: async (params) => {
// 执行逻辑
return { result: 'success' };
}
}
]
};
把这个插件放到 `~/.openclaw/plugins/my-plugin/` 目录下,然后重启网关就能用了。
## 五、插件的常用场景
### 场景一:自定义快捷命令
比如你想添加一个快捷命令,输入 `/weather` 就自动查天气:
// weather-plugin/index.js
module.exports = {
name: 'weather-quick-command',
commands: [
{
name: 'weather',
aliases: ['/天气', '/weather'],
handler: async (args, context) => {
// 调用天气 API 获取数据
const weather = await fetch('https://api.weather.com/...');
return `今天的天气是:${weather.description}`;
}
}
]
};
### 场景二:集成第三方服务
想把公司内部的系统接入 OpenClaw?写个插件就行:
// company-plugin/index.js
module.exports = {
name: 'company-integration',
tools: [
{
name: 'queryCRM',
description: '查询 CRM 系统中的客户信息',
schema: {
customerId: { type: 'string', required: true }
},
execute: async ({ customerId }) => {
const data = await crmApi.getCustomer(customerId);
return data;
}
},
{
name: 'createTicket',
description: '在工单系统创建工单',
execute: async ({ title, content }) => {
const ticket = await ticketSystem.create({ title, content });
return `工单已创建,编号:${ticket.id}`;
}
}
]
};
### 场景三:扩展通知渠道
想让 OpenClaw 通知你的时候不只是发消息,还能推送到钉钉、企业微信或者飞书?
// notification-plugin/index.js
module.exports = {
name: 'multi-channel-notification',
hooks: {
'notification:send': async (notification, channels) => {
if (channels.includes('dingtalk')) {
await dingtalkBot.send(notification);
}
if (channels.includes('feishu')) {
await feishuWebhook.post(notification);
}
}
}
};
## 六、配置插件
有些插件支持配置文件,在 `~/.openclaw/config/plugins.json` 里可以统一管理:
{
"plugins": {
"@openclaw/v": {
"enabled": true,
"config": {
"voice": "female",
"language": "zh-CN"
}
},
"my-custom-plugin": {
"enabled": true,
"config": {
"apiKey": "your-api-key"
}
}
}
}
## 七、管理插件
### 查看插件状态
openclaw plugins list
### 启用 / 禁用插件
# 禁用某个插件
openclaw plugins disable my-plugin
# 启用某个插件
openclaw plugins enable my-plugin
### 卸载插件
# 卸载插件
openclaw plugins uninstall my-plugin
或者直接删除插件文件夹:
rm -rf ~/.openclaw/plugins/my-plugin
## 八、插件开发注意事项
如果你打算自己写插件,有几点需要注意:
### 1. 错误处理要完善
插件里的代码可能出现各种异常,一定要做好错误捕获:
execute: async (params) => {
try {
const result = await doSomething(params);
return result;
} catch (error) {
return { error: error.message };
}
}
### 2. 不要阻塞主线程
插件里的操作如果是耗时的,一定要用异步方式,不要用同步阻塞操作:
// ✅ 正确:异步执行
execute: async (params) => {
const data = await fetchData(params);
return data;
}
// ❌ 错误:同步阻塞
execute: (params) => {
const data = syncFetchData(params); // 不要这样!
return data;
}
### 3. 遵循安全规范
插件可以执行任意代码,所以安装插件的时候要确保来源可靠。不要安装来路不明的插件。
### 4. 查看日志排错
插件出问题的时候,查看 OpenClaw 的日志很有帮助:
# 查看最近的日志
openclaw logs --tail 100
# 或者直接看日志文件
cat ~/.openclaw/logs/gateway.log
## 九、官方插件推荐
OpenClaw 官方维护了一批高质量插件:
| 插件包 | 功能描述 |
|——–|———-|
| `@openclaw/v` | 语音通话功能 |
| `@openclaw/calendar` | 日历集成(Google Calendar / Outlook) |
| `@openclaw/contacts` | 联系人管理 |
| `@openclaw/sms` | 短信发送 |
| `@openclaw/ssh` | SSH 远程连接 |
| `@openclaw/docker` | Docker 容器管理 |
安装方式都是:
openclaw plugins install @openclaw/插件名
## 十、写在最后
好了,插件系统就讲到这里!总结一下今天的内容:
– ✅ 搞清楚了技能和插件的区别
– ✅ 学会了查看、安装、管理插件
– ✅ 了解了插件的几种常见用法
– ✅ 知道了开发插件的注意事项
– ✅ 看到了官方推荐的插件列表
插件系统是 OpenClaw 最灵活的扩展方式,如果你有开发能力,建议多尝试定制自己的专属功能!有问题随时留言!
**相关阅读:** OpenClaw 新手入门完全指南 / OpenClaw 技能商店使用指南 / OpenClaw 命令大全
外部链接: OpenClaw 中文文档 / GitHub 源码





暂无评论内容