feishu-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese飞书全通道自动化
Full-channel Automation for Lark
使用 lark-mcp 工具实现飞书平台的全面自动化操作。
Implement comprehensive automation operations on the Lark platform using the lark-mcp tool.
核心功能
Core Features
1. 多维表格(Bitable)
1. Bitable
- 创建多维表格和数据表
- 添加、修改、删除字段
- 增删改查记录数据
- 批量导入导出数据
- 数据筛选和排序
- Create Bitable and data tables
- Add, modify, and delete fields
- Create, read, update, and delete record data
- Batch import and export data
- Data filtering and sorting
2. 消息发送
2. Message Sending
- 发送文本、富文本、卡片消息
- 群组消息和私聊消息
- 消息模板和交互式卡片
- 文件和图片发送
- Send text, rich text, and card messages
- Group messages and private messages
- Message templates and interactive cards
- File and image sending
3. 文档管理
3. Document Management
- 搜索云文档
- 创建新文档
- 编辑文档内容
- 文档权限管理
- 文档协作者管理
- Search cloud documents
- Create new documents
- Edit document content
- Document permission management
- Document collaborator management
4. 群组管理
4. Group Management
- 创建群组
- 添加/移除成员
- 获取群组列表
- 群组信息查询
- Create groups
- Add/remove members
- Get group lists
- Query group information
5. 知识库(Wiki)
5. Wiki
- 搜索知识库节点
- 获取节点详情
- 创建和管理知识库内容
- Search Wiki nodes
- Get node details
- Create and manage Wiki content
6. 日历和任务
6. Calendar and Tasks
- 创建和查询日历事件
- 创建和管理任务
- 任务分配和跟踪
- Create and query calendar events
- Create and manage tasks
- Task assignment and tracking
快速开始
Quick Start
检查 MCP 可用性
Check MCP Availability
javascript
// 检查 lark-mcp 工具是否可用
// 可用工具前缀:mcp__lark-mcp_javascript
// 检查 lark-mcp 工具是否可用
// 可用工具前缀:mcp__lark-mcp_发送测试消息
Send Test Message
javascript
// 发送文本消息到群组
await mcp__lark-mcp_sendMessage({
receive_id: "oc_xxxxxxxxx",
msg_type: "text",
content: JSON.stringify({
text: "Hello from Clawdbot!"
})
});javascript
// 发送文本消息到群组
await mcp__lark-mcp_sendMessage({
receive_id: "oc_xxxxxxxxx",
msg_type: "text",
content: JSON.stringify({
text: "Hello from Clawdbot!"
})
});工作流程
Workflows
数据同步流程
Data Sync Workflow
- 连接数据源
- 转换数据格式
- 创建/更新多维表格
- 批量写入数据
- 发送通知
- Connect to data source
- Convert data format
- Create/update Bitable
- Batch write data
- Send notifications
消息推送流程
Message Push Workflow
- 触发事件(定时/事件驱动)
- 构建消息内容
- 获取接收者 ID
- 发送消息
- 记录日志
- Trigger event (scheduled/event-driven)
- Build message content
- Get recipient ID
- Send message
- Record logs
文档自动化流程
Document Automation Workflow
- 获取文档模板
- 填充内容
- 创建新文档
- 设置权限
- 分享给团队
- Get document template
- Fill in content
- Create new document
- Set permissions
- Share with team
API 工具参考
API Tool Reference
多维表格相关
Bitable Related
- - 创建多维表格
createBitable - - 创建数据表
createTable - - 添加记录
addRecord - - 更新记录
updateRecord - - 删除记录
deleteRecord - - 搜索记录
searchRecords - - 获取记录详情
getRecord
- - Create Bitable
createBitable - - Create data table
createTable - - Add record
addRecord - - Update record
updateRecord - - Delete record
deleteRecord - - Search records
searchRecords - - Get record details
getRecord
消息相关
Message Related
- - 发送消息
sendMessage - - 获取消息历史
getMessages - - 回复消息
replyMessage
- - Send message
sendMessage - - Get message history
getMessages - - Reply to message
replyMessage
文档相关
Document Related
- - 搜索文档
searchDocs - - 创建文档
createDoc - - 获取文档内容
getDoc - - 更新文档
updateDoc - - 设置文档权限
setDocPermission
- - Search documents
searchDocs - - Create document
createDoc - - Get document content
getDoc - - Update document
updateDoc - - Set document permission
setDocPermission
群组相关
Group Related
- - 创建群组
createGroup - - 添加成员
addMember - - 获取群组列表
getGroupList - - 获取群组信息
getGroupInfo
- - Create group
createGroup - - Add member
addMember - - Get group list
getGroupList - - Get group information
getGroupInfo
实用场景
Practical Scenarios
1. 自动化日报收集
1. Automated Daily Report Collection
- 每日定时创建表格记录
- 成员填写日报
- 自动汇总统计
- 发送到群组
- Scheduled daily table record creation
- Members fill in daily reports
- Automatic summary and statistics
- Send to groups
2. 审批流程
2. Approval Process
- 创建审批表格
- 监听状态变更
- 自动通知审批人
- 记录审批历史
- Create approval tables
- Monitor status changes
- Automatically notify approvers
- Record approval history
3. 任务管理
3. Task Management
- 创建任务表格
- 分配任务给成员
- 发送任务提醒
- 跟踪完成状态
- Create task tables
- Assign tasks to members
- Send task reminders
- Track completion status
4. 客户管理
4. Customer Management
- 客户信息表格
- 跟进记录
- 自动提醒
- 数据可视化
- Customer information tables
- Follow-up records
- Automatic reminders
- Data visualization
5. 报表生成
5. Report Generation
- 从表格提取数据
- 生成统计报表
- 创建飞书文档
- 定期推送更新
- Extract data from tables
- Generate statistical reports
- Create Lark documents
- Regularly push updates
最佳实践
Best Practices
认证配置
Authentication Configuration
- 使用提供的 App ID 和 App Secret
- 遵守 API 调用频率限制
- 缓存 access_token
- Use provided App ID and App Secret
- Comply with API call frequency limits
- Cache access_token
数据操作
Data Operations
- 批量操作使用分页
- 数据写入前验证格式
- 错误处理和重试
- 记录操作日志
- Use pagination for batch operations
- Validate data format before writing
- Error handling and retries
- Record operation logs
消息发送
Message Sending
- 使用交互式卡片提升体验
- 合理控制发送频率
- 避免发送敏感信息
- 支持用户交互
- Use interactive cards to enhance experience
- Control sending frequency appropriately
- Avoid sending sensitive information
- Support user interaction
权限管理
Permission Management
- 最小权限原则
- 定期审查权限
- 协作者生命周期管理
- Principle of least privilege
- Regular permission reviews
- Collaborator lifecycle management
错误处理
Error Handling
常见错误
Common Errors
- 权限不足 - 检查应用权限配置
- 限流错误 - 实现重试和等待
- 无效 ID - 验证用户/群组 ID 格式
- 网络错误 - 实现重试机制
- Insufficient permissions - Check app permission configuration
- Rate limiting errors - Implement retries and waiting
- Invalid ID - Verify user/group ID format
- Network errors - Implement retry mechanism
重试策略
Retry Strategy
- 指数退避算法
- 最大重试次数限制
- 记录失败请求
- 通知管理员
- Exponential backoff algorithm
- Maximum retry limit
- Record failed requests
- Notify administrators
安全注意事项
Security Notes
- 保护 App Secret
- 不要在日志中记录敏感信息
- 使用环境变量管理凭证
- 定期轮换访问令牌
- 遵守数据隐私法规
- Protect App Secret
- Do not record sensitive information in logs
- Use environment variables to manage credentials
- Rotate access tokens regularly
- Comply with data privacy regulations
示例代码
Sample Code
创建多维表格并添加数据
Create Bitable and Add Data
javascript
// 创建多维表格
const bitable = await mcp__lark-mcp_createBitable({
name: "项目管理",
folder_token: "folder_token"
});
// 创建数据表
const table = await mcp__lark-mcp_createTable({
app_token: bitable.app_token,
table: {
name: "任务列表",
fields: [
{ field_name: "任务名称", type: 1 },
{ field_name: "负责人", type: 13 },
{ field_name: "状态", type: 3 },
{ field_name: "截止日期", type: 5 }
]
}
});
// 添加记录
await mcp__lark-mcp_addRecord({
app_token: bitable.app_token,
table_id: table.table_id,
fields: {
"任务名称": "完成项目文档",
"负责人": "user_id",
"状态": "进行中",
"截止日期": Date.now()
}
});javascript
// 创建多维表格
const bitable = await mcp__lark-mcp_createBitable({
name: "项目管理",
folder_token: "folder_token"
});
// 创建数据表
const table = await mcp__lark-mcp_createTable({
app_token: bitable.app_token,
table: {
name: "任务列表",
fields: [
{ field_name: "任务名称", type: 1 },
{ field_name: "负责人", type: 13 },
{ field_name: "状态", type: 3 },
{ field_name: "截止日期", type: 5 }
]
}
});
// 添加记录
await mcp__lark-mcp_addRecord({
app_token: bitable.app_token,
table_id: table.table_id,
fields: {
"任务名称": "完成项目文档",
"负责人": "user_id",
"状态": "进行中",
"截止日期": Date.now()
}
});发送卡片消息
Send Card Message
javascript
await mcp__lark-mcp_sendMessage({
receive_id: "chat_id",
msg_type: "interactive",
content: JSON.stringify({
config: {
wide_screen_mode: true
},
header: {
template: "turquoise",
title: {
content: "重要通知",
tag: "plain_text"
}
},
elements: [
{
tag: "div",
text: {
content: "**项目里程碑已完成**",
tag: "lark_md"
}
},
{
tag: "action",
actions: [
{
tag: "button",
text: {
content: "查看详情",
tag: "plain_text"
},
type: "primary",
url: "https://example.com"
}
]
}
]
})
});javascript
await mcp__lark-mcp_sendMessage({
receive_id: "chat_id",
msg_type: "interactive",
content: JSON.stringify({
config: {
wide_screen_mode: true
},
header: {
template: "turquoise",
title: {
content: "重要通知",
tag: "plain_text"
}
},
elements: [
{
tag: "div",
text: {
content: "**项目里程碑已完成**",
tag: "lark_md"
}
},
{
tag: "action",
actions: [
{
tag: "button",
text: {
content: "查看详情",
tag: "plain_text"
},
type: "primary",
url: "https://example.com"
}
]
}
]
})
});批量导入数据
Batch Import Data
javascript
const data = [
{ name: "张三", phone: "13800138000" },
{ name: "李四", phone: "13900139000" }
];
for (const item of data) {
await mcp__lark-mcp_addRecord({
app_token: "app_token",
table_id: "table_id",
fields: {
"姓名": item.name,
"电话": item.phone
}
});
// 避免限流
await new Promise(resolve => setTimeout(resolve, 100));
}javascript
const data = [
{ name: "张三", phone: "13800138000" },
{ name: "李四", phone: "13900139000" }
];
for (const item of data) {
await mcp__lark-mcp_addRecord({
app_token: "app_token",
table_id: "table_id",
fields: {
"姓名": item.name,
"电话": item.phone
}
});
// 避免限流
await new Promise(resolve => setTimeout(resolve, 100));
}配置验证
Configuration Validation
检查 MCP 服务器
Check MCP Server
bash
undefinedbash
undefined检查 .claude.json 中的 lark-mcp 配置
检查 .claude.json 中的 lark-mcp 配置
cat ~/.claude.json | grep -A 15 "lark-mcp"
undefinedcat ~/.claude.json | grep -A 15 "lark-mcp"
undefined测试连接
Test Connection
javascript
// 发送测试消息验证连接
await mcp__lark-mcp_sendMessage({
receive_id: "your_chat_id",
msg_type: "text",
content: JSON.stringify({
text: "🎉 飞书 MCP 连接成功!"
})
});javascript
// 发送测试消息验证连接
await mcp__lark-mcp_sendMessage({
receive_id: "your_chat_id",
msg_type: "text",
content: JSON.stringify({
text: "🎉 飞书 MCP 连接成功!"
})
});进阶用法
Advanced Usage
Webhook 集成
Webhook Integration
- 监听飞书 Webhook 事件
- 自动触发工作流
- 实时数据同步
- Listen to Lark Webhook events
- Automatically trigger workflows
- Real-time data sync
自动化定时任务
Automated Scheduled Tasks
- 定时发送报告
- 自动数据备份
- 定期清理
- Scheduled report sending
- Automatic data backup
- Regular cleanup
跨平台集成
Cross-platform Integration
- 与 GitHub 集成(Issue 同步)
- 与邮件集成(通知推送)
- 与日历集成(日程管理)
- Integrate with GitHub (Issue sync)
- Integrate with email (notification push)
- Integrate with calendar (schedule management)
故障排查
Troubleshooting
MCP 工具不可用
MCP Tool Unavailable
- 重启 Claude Desktop
- 检查网络连接
- 验证凭证是否有效
- 查看错误日志
- Restart Claude Desktop
- Check network connection
- Verify credentials are valid
- View error logs
API 调用失败
API Call Failed
- 检查应用权限配置
- 验证用户/群组 ID
- 查看限流状态
- 检查数据格式
- Check app permission configuration
- Verify user/group ID
- Check rate limiting status
- Check data format
权限不足
Insufficient Permissions
- 登录飞书开放平台
- 检查应用权限范围
- 重新授权
- 等待权限生效
- Log in to Lark Open Platform
- Check app permission scope
- Re-authorize
- Wait for permissions to take effect