5 分钟搭建企业 AI 助手 - 零代码,即插即用。
# 编辑 ~/.openclaw/config/channels.json
{
"feishu": {
"enabled": true,
"appId": "YOUR_APP_ID",
"appSecret": "YOUR_APP_SECRET",
"encryptKey": "YOUR_ENCRYPT_KEY",
"verificationToken": "YOUR_VERIFICATION_TOKEN"
}
}
```
# 在飞书群@机器人
@Jarvis 帮我写一份周报
```
# 安装依赖
npm install @larksuiteoapi/node-sdk axios
# 创建集成脚本
cat > feishu-bot.js << 'EOF'
const lark = require('@larksuiteoapi/node-sdk');
const axios = require('axios');
const client = new lark.Client({
appId: process.env.FEISHU_APP_ID,
appSecret: process.env.FEISHU_APP_SECRET,
});
const OPENCLAW_URL = process.env.OPENCLAW_URL || 'http://localhost:3000';
// 处理飞书消息
client.im.message.subscribe({
on: async (event) => {
const { message } = event;
const content = JSON.parse(message.content);
// 发送到 OpenClaw
const response = await axios.post(`${OPENCLAW_URL}/api/chat`, {
message: content.text,
userId: message.sender_id,
channel: 'feishu',
});
// 回复消息
await client.im.message.create({
receive_id_type: 'chat_id',
params: { receive_id: message.chat_id },
data: {
msg_type: 'text',
content: JSON.stringify({ text: response.data.reply })
}
});
}
});
EOF
# 运行
FEISHU_APP_ID=xxx FEISHU_APP_SECRET=xxx node feishu-bot.js
# config/group-assistant.yaml
prompts:
tech_group:
system: "你是技术群的 AI 助手,专业、简洁、直接。"
temperature: 0.3
product_group:
system: "你是产品群的 AI 助手,关注用户体验、需求分析。"
temperature: 0.7
# 自动回复规则
AUTO_REPLY = {
'价格': '基础版 ¥99,高级版 ¥299',
'售后': '请联系售后微信:xxx',
'发票': '提供增值税普通发票,开票请联系财务',
}
def handle_keyword(text):
for keyword, reply in AUTO_REPLY.items():
if keyword in text:
return reply
return None # 转到 OpenClaw 处理
// 每天早上 9 点发送日报提醒
const schedule = require('node-schedule');
schedule.scheduleJob('0 9 * * *', async () => {
await client.im.message.create({
receive_id_type: 'chat_id',
params: { receive_id: 'WORK_GROUP_ID' },
data: {
msg_type: 'interactive',
content: JSON.stringify({
config: {
wide_screen_mode: true
},
elements: [{
tag: 'div',
text: {
tag: 'lark_md',
content: '📊 **日报提醒**\n\n请大家在今天 18:00 前提交日报'
}
}]
})
}
});
});
// 分析群聊数据,生成报告
async function generateReport(chatId) {
const messages = await client.im.message.list({
params: {
container_id_type: 'chat_id',
container_id: chatId,
page_size: 100
}
});
// 发送给 OpenClaw 分析
const analysis = await axios.post(`${OPENCLAW_URL}/api/analyze`, {
data: messages,
task: '总结今天的讨论要点'
});
return analysis.data;
}
// 发送精美卡片
await client.im.message.create({
receive_id_type: 'chat_id',
params: { receive_id: chatId },
data: {
msg_type: 'interactive',
content: JSON.stringify({
config: { wide_screen_mode: true },
header: {
title: {
tag: 'plain_text',
content: '🚀 AI 分析报告'
}
},
elements: [{
tag: 'div',
text: {
tag: 'lark_md',
content: '**关键结论**\n- 用户增长 20%\n- 留存率 85%'
}
}]
})
}
});
// 处理上传的文件
if (message.msg_type === 'file') {
const fileKey = JSON.parse(message.content).file_key;
// 下载文件
const file = await client.im.file.download({
params: { type: 'file', file_key: fileKey }
});
// 发送给 OpenClaw 分析
const result = await axios.post(`${OPENCLAW_URL}/api/analyze-file`, {
file: file.data,
task: '总结这份文档的关键信息'
});
}
// 不同群用不同 Agent
const AGENTS = {
'TECH_GROUP_ID': 'jarvis', // 技术群
'PRODUCT_GROUP_ID': 'assistant', // 产品群
'SALES_GROUP_ID': 'sales-bot', // 销售群
};
async function routeMessage(chatId, text) {
const agent = AGENTS[chatId] || 'default';
return await axios.post(`${OPENCLAW_URL}/api/chat`, {
message: text,
agent: agent
});
}
# 飞书应用配置
app:
id: "cli_xxxxxxxxx"
secret: "xxxxxxxxxxxxxxxx"
encrypt_key: "xxxxxxxxxxxxxxxx"
verification_token: "xxxxxxxxxxxxxxxx"
# 机器人配置
bot:
name: "Jarvis"
avatar: "https://example.com/avatar.png"
welcome_message: "你好!我是 AI 助手 Jarvis,有什么可以帮你的?"
# 自动回复
auto_reply:
enabled: true
rules:
- keywords: ["价格", "多少钱"]
reply: "基础版 ¥99,高级版 ¥299,企业定制请联系客服"
- keywords: ["发票", "开票"]
reply: "提供增值税普通发票,请联系财务"
- keywords: ["售后", "客服"]
reply: "售后微信:xxx"
# AI 配置
ai:
model: "gpt-4"
temperature: 0.7
max_tokens: 2000
system_prompt: "你是企业 AI 助手,专业、高效、简洁。"
# 群配置
groups:
- chat_id: "oc_xxxxxxxxx"
name: "技术群"
agent: "jarvis-tech"
enabled_commands: ["/code", "/review", "/help"]
- chat_id: "oc_xxxxxxxxx"
name: "产品群"
agent: "jarvis-product"
enabled_commands: ["/pr", "/analyze", "/summary"]
# 定时任务
schedule:
- cron: "0 9 * * *"
message: "📊 日报提醒:请在 18:00 前提交日报"
target_groups: ["ALL"]
- cron: "0 18 * * *"
command: "/summary"
target_groups: ["技术群", "产品群"]
在飞书开放平台,应用需要开通以下权限:
im:message(发送消息)im:message:group_at_msg(群@消息)contact:user.base:readonly(读取用户信息)// 使用消息队列
const queue = require('bull');
const messageQueue = new queue('feishu-messages');
// 生产者
client.im.message.subscribe({
on: (event) => {
messageQueue.add(event);
}
});
// 消费者(可横向扩展)
messageQueue.process(async (job) => {
await handleFeishuMessage(job.data);
});
# 本地运行
npm install
npm start
# 使用 Docker
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["node", "server.js"]
版本:1.0.0
更新:2026-03-17
作者:OpenClaw Community
许可:MIT
共 1 个版本
暂无安全检测报告