OpenClaw 私人助理:打造你的专属 AI 助手
OpenClaw 私人助理:打造你的专属 AI 助手
在这个信息爆炸的时代,一个得力的私人助理可以大幅提升你的生活质量和工作效率。OpenClaw 可以被打造成一个功能强大的私人助理,帮助你管理日程、整理信息、提醒待办事项等。本文将详细介绍如何用 OpenClaw 打造你的专属私人助理。
私人助理的核心功能
功能概览
| 功能模块 | 说明 | 示例 |
|---|---|---|
| 日程管理 | 安排和提醒日程 | "明天下午3点有会议" |
| 待办管理 | 记录和跟踪任务 | "提醒我买牛奶" |
| 信息整理 | 收集和整理资料 | "帮我保存这个链接" |
| 生活助手 | 提供生活便利 | "天气怎么样" |
| 学习助手 | 辅助学习和研究 | "解释这个概念" |
基础配置
配置文件
# config/app.yaml
app:
name: "我的私人助理"
description: "您的专属 AI 助手"
# 启用相关插件
plugins:
- telegram
- discord
- memory
- cron
# 记忆配置
memory:
enabled: true
type: "file"
path: "./data/memory"
retentionDays: 90
创建核心技能
创建以下技能目录结构:
skills/
├── personal-assistant/
│ ├── scheduler/ # 日程管理
│ ├── todo/ # 待办管理
│ ├── notes/ # 笔记管理
│ ├── reminders/ # 提醒功能
│ └── knowledge/ # 知识库
日程管理技能
日程管理功能
// skills/scheduler/index.js
module.exports = {
name: 'scheduler',
description: '日程管理',
async execute(params, context) {
const { action, title, time, duration, participants } = params;
const userId = context.user?.id;
switch (action) {
case 'add':
// 添加日程
const event = await context.calendar.create({
title,
startTime: time,
duration: duration || 60,
participants: participants || [],
reminders: [15, 5] // 提前15分钟和5分钟提醒
});
return {
type: 'text',
content: `✅ 已添加日程:\n📅 ${title}\n🕐 ${time}\n⏱️ ${duration || 60}分钟`
};
case 'list':
// 查看日程
const events = await context.calendar.list({
startDate: new Date(),
endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) // 一周
});
if (events.length === 0) {
return { type: 'text', content: '未来一周没有日程安排' };
}
const eventList = events.map((e, i) =>
`${i + 1}. ${e.title}\n 🕐 ${e.startTime}`
).join('\n\n');
return {
type: 'text',
content: `📅 未来日程:\n\n${eventList}`
};
case 'delete':
// 删除日程
await context.calendar.delete({ title });
return { type: 'text', content: `已删除日程:${title}` };
}
}
};
待办管理技能
待办事项功能
// skills/todo/index.js
module.exports = {
name: 'todo',
description: '待办事项管理',
async execute(params, context) {
const { action, task, priority, dueDate, tags } = params;
const userId = context.user?.id;
switch (action) {
case 'add':
// 添加待办
const todo = await context.todos.add({
task,
priority: priority || 'medium',
dueDate,
tags: tags || [],
userId
});
const priorityEmoji = {
high: '🔴',
medium: '🟡',
low: '🟢'
};
return {
type: 'text',
content: `✅ 已添加待办:\n${priorityEmoji[priority || 'medium']} ${task}${dueDate ? '\n📅 截止:' + dueDate : ''}`
};
case 'list':
// 列出待办
const todos = await context.todos.list({ userId });
if (todos.length === 0) {
return { type: 'text', content: '🎉 当前没有待办事项!' };
}
const pending = todos.filter(t => !t.completed);
const completed = todos.filter(t => t.completed);
let output = '';
if (pending.length > 0) {
output += '📋 待办事项:\n';
output += pending.map((t, i) =>
`${i + 1}. [ ] ${t.task}${t.priority === 'high' ? ' 🔴' : ''}`
).join('\n');
}
if (completed.length > 0) {
output += '\n\n✅ 已完成:\n';
output += completed.map((t, i) =>
`${i + 1}. [x] ${t.task}`
).join('\n');
}
return { type: 'text', content: output };
case 'complete':
// 标记完成
await context.todos.complete({ task, userId });
return { type: 'text', content: `✅ 已完成:${task}` };
case 'delete':
// 删除待办
await context.todos.delete({ task, userId });
return { type: 'text', content: `🗑️ 已删除:${task}` };
}
}
};
提醒功能
智能提醒
// skills/reminders/index.js
module.exports = {
name: 'reminder',
description: '提醒设置',
async execute(params, context) {
const { action, message, time, repeat } = params;
const userId = context.user?.id;
switch (action) {
case 'set':
// 设置提醒
const reminder = await context.reminders.set({
message,
time,
repeat: repeat || 'once',
userId,
notify: true
});
return {
type: 'text',
content: `⏰ 已设置提醒:${message}\n🕐 时间:${time}`
};
case 'list':
// 查看提醒
const reminders = await context.reminders.list({ userId });
if (reminders.length === 0) {
return { type: 'text', content: '没有设置任何提醒' };
}
const list = reminders.map(r =>
`• ${r.message} - ${r.time}`
).join('\n');
return { type: 'text', content: `⏰ 您的提醒:\n${list}` };
case 'cancel':
// 取消提醒
await context.reminders.cancel({ message, userId });
return { type: 'text', content: `已取消提醒:${message}` };
}
}
};
定时任务:自动提醒
配置定时提醒
# config/cron.yaml
tasks:
# 每天早上提醒待办
- name: "morning-todo-reminder"
schedule: "0 8 * * *"
skill: "todo-reminder"
params:
type: "pending"
notify:
enabled: true
# 每周回顾
- name: "weekly-review"
schedule: "0 18 * * 5" # 周五下午6点
skill: "weekly-summary"
params:
types:
- "todo"
- "calendar"
- "notes"
知识管理
个人知识库
// skills/knowledge/index.js
module.exports = {
name: 'knowledge',
description: '个人知识库',
async execute(params, context) {
const { action, title, content, tags, query } = params;
const userId = context.user?.id;
switch (action) {
case 'add':
// 添加知识
await context.knowledge.add({
title,
content,
tags: tags || [],
userId
});
return {
type: 'text',
content: `💾 已保存知识:${title}`
};
case 'search':
// 搜索知识
const results = await context.knowledge.search({
query,
userId,
limit: 5
});
if (results.length === 0) {
return { type: 'text', content: '没有找到相关内容' };
}
const output = results.map(r =>
`📄 ${r.title}\n${r.content.substring(0, 100)}...`
).join('\n\n');
return { type: 'text', content: output };
case 'list':
// 列出所有知识
const items = await context.knowledge.list({ userId });
return {
type: 'text',
content: `💡 您的知识库(共${items.length}条):\n\n` +
items.map(i => `• ${i.title}`).join('\n')
};
}
}
};
生活助手功能
天气查询
// skills/weather/index.js
module.exports = {
name: 'weather',
description: '天气查询',
async execute(params, context) {
const { city = '北京' } = params;
const weather = await context.http.get(
`https://api.weather.com/v1/current`,
{ city, key: process.env.WEATHER_API_KEY }
);
const { condition, temperature, humidity, wind, tomorrow } = weather;
return {
type: 'text',
content: `🌤️ ${city}今日天气\n\n` +
`天气:${condition}\n` +
`温度:${temperature}°C\n` +
`湿度:${humidity}%\n` +
`风速:${wind}km/h\n\n` +
`明日天气:${tomorrow}`
};
}
};
快递查询
// skills/express/index.js
module.exports = {
name: 'express',
description: '快递查询',
async execute(params, context) {
const { number, company } = params;
const result = await context.http.get(
`https://api.express.com/trace`,
{ number, company }
);
if (!result.success) {
return { type: 'text', content: '未找到快递信息' };
}
const tracks = result.tracks.slice(0, 5).map(t =>
`• ${t.time} - ${t.status}`
).join('\n');
return {
type: 'text',
content: `📦 快递进度:${number}\n\n${tracks}`
};
}
};
私人助理配置
触发词配置
# config/skills.yaml
skills:
- path: "./skills/scheduler"
enabled: true
triggers:
- "添加日程"
- "查看日程"
- "删除日程"
- "安排会议"
- path: "./skills/todo"
enabled: true
triggers:
- "待办"
- "添加任务"
- "完成任务"
- "查看任务"
- path: "./skills/reminders"
enabled: true
triggers:
- "提醒"
- "设置提醒"
- "取消提醒"
- path: "./skills/knowledge"
enabled: true
triggers:
- "保存"
- "搜索"
- "知识库"
- path: "./skills/weather"
enabled: true
triggers:
- "天气"
个性化配置
# config/prompts.yaml
system:
role: |
你是用户的私人助理"小管家",性格友好、细心、专业。
你需要:
1. 主动关心用户
2. 记住用户的偏好
3. 提供有用的建议
behavior: |
- 语气亲切、自然
- 回答简洁明了
- 主动提供相关信息
preferences:
timezone: "Asia/Shanghai"
language: "zh-CN"
dateFormat: "YYYY-MM-DD"
使用示例
对话示例
用户:明天下午3点帮我安排一个会议
助手:好的,请问会议的主题是什么?
用户:团队周会
助手:已添加日程:
📅 团队周会
🕐 明天下午3:00
⏱️ 60分钟
需要我通知参会人员吗?
用户:提醒我周五之前完成报告
助手:✅ 已添加待办:
🔴 提醒我周五之前完成报告
📅 截止:本周五
用户:帮我保存这个链接 https://example.com ,标题是"有用的文章"
助手:💾 已保存知识:
有用的文章
标签:无
需要添加标签吗?
进阶功能
1. 语音提醒
// 支持语音播报提醒
context.notifier.notify({
type: 'voice',
userId,
content: '您有一个重要会议将在15分钟后开始'
});
2. 多平台同步
# 配置多平台同步
notifications:
platforms:
- telegram
- discord
- email
sync:
enabled: true
interval: 300 # 5分钟同步一次
3. 智能建议
// 基于用户习惯的智能建议
async function suggestActions(context) {
const recentTodos = await context.todos.list({
userId,
limit: 5,
orderBy: 'createdAt:desc'
});
if (recentTodos.length > 0 && !recentTodos[0].completed) {
return '看起来你有一个待办事项还未完成,要现在处理吗?';
}
return null;
}
总结
通过 OpenClaw,你可以打造一个功能丰富的私人助理:
- ✅ 日程管理:智能安排和提醒
- ✅ 待办追踪:清晰管理任务
- ✅ 知识积累:建立个人知识库
- ✅ 生活助手:天气、快递等信息查询
- ✅ 自动提醒:定时任务自动化
你的私人助理可以根据你的需求不断学习和进化,成为真正懂你的 AI 伙伴。
相关阅读: - OpenClaw 技能开发 - OpenClaw 定时任务 - OpenClaw 自动化工作流