世界上有一种魔法,叫自动化。早上8点03分,当我还在被窝里赖床时,我的AI Agent已经处理完了50封邮件、发了3条推文、分析了昨日数据。这就是OpenClaw的魔力...
本文分享10个经过实战验证的OpenClaw自动化场景,每个都包含完整配置和代码,拿来即用。
需求:自动分类邮件、提取关键信息、重要邮件即时通知
# email_automation.yaml
triggers:
- type: imap
server: imap.gmail.com
username: ${EMAIL_USER}
password: ${EMAIL_PASS}
check_interval: 300 # 5分钟检查一次
workflow:
steps:
- action: fetch_emails
limit: 20
- action: classify_email
model: gpt-4o-mini
categories:
- urgent # 紧急
- important # 重要
- newsletter # 订阅
- spam # 垃圾
- action: extract_info
fields:
- sender
- subject
- key_points
- action_items
- action: conditional
condition: "category == 'urgent'"
then:
- action: send_notification
channel: telegram
message: "🚨 紧急邮件:{{subject}} from {{sender}}"
else:
- action: archive
folder: "AI_Processed"
需求:根据热点自动生成博客文章并发布
# content_automation.yaml
triggers:
- type: cron
schedule: "0 9 * * *" # 每天上午9点
workflow:
steps:
- action: search_trends
source: [google_trends, twitter, reddit]
count: 5
- action: select_topic
criteria: relevance > 0.7 AND competition < 0.5
- action: research
depth: comprehensive
sources: 10
- action: write_article
model: claude-3-opus
style: engaging
length: 1500
seo_optimized: true
- action: generate_images
count: 3
style: modern
- action: publish
platform: wordpress
status: draft # 先保存草稿,人工审核后发布
- action: notify
channel: slack
message: "✅ 新文章已生成:{{title}}"
需求:自动收集多平台数据,生成可视化报告
# daily_report.yaml
triggers:
- type: cron
schedule: "0 8 * * *" # 每天早8点
workflow:
steps:
- action: collect_metrics
sources:
- name: google_analytics
metrics: [users, sessions, bounce_rate]
- name: stripe
metrics: [revenue, new_subscriptions, churn]
- name: github
metrics: [stars, forks, issues]
- action: analyze_data
operations:
- calculate_growth
- detect_anomalies
- compare_to_previous
- action: generate_chart
type: dashboard
charts:
- line: revenue_trend
- bar: traffic_source
- pie: user_device
- action: write_report
template: daily_report
sections:
- summary
- key_metrics
- insights
- recommendations
- action: send_email
to: ["team@miaoquai.com"]
subject: "📊 每日数据报告 - {{date}}"
attachments:
- report.pdf
- dashboard.png
需求:自动处理Issues、Review PR、生成Release Notes
# github_automation.yaml
triggers:
- type: webhook
event: github
filters:
- issue.opened
- pull_request.opened
- release.created
workflows:
# 自动分类Issue
issue_triage:
condition: "event == 'issue.opened'"
steps:
- action: analyze_issue
extract:
- bug_keywords
- feature_keywords
- priority_indicators
- action: label_issue
labels:
- "{{category}}" # bug/feature/docs
- "{{priority}}" # high/medium/low
- action: auto_reply
message: |
感谢提交 Issue!
我们已将其分类为 {{category}},优先级 {{priority}}。
预计处理时间:{{estimated_time}}
如有补充信息,请随时更新。
# PR自动Review
pr_review:
condition: "event == 'pull_request.opened'"
steps:
- action: analyze_code
checks:
- code_style
- security_issues
- test_coverage
- breaking_changes
- action: post_review
type: comment
content: |
## 🤖 AI Code Review
### 检查结果
{{#each checks}}
- {{status}} {{name}}: {{message}}
{{/each}}
### 建议
{{recommendations}}
需求:自动发布内容、互动回复、数据分析
# social_automation.yaml
workflows:
# 定时发布
scheduled_posts:
trigger: cron
schedule: "0 10,14,18 * * *" # 每天10/14/18点
steps:
- action: select_content
from: content_calendar
platform: twitter
- action: optimize_for_platform
max_length: 280
add_hashtags: true
- action: post
platforms: [twitter, linkedin]
- action: track_performance
metrics: [impressions, engagements, clicks]
# 自动回复
auto_reply:
trigger: mention
platforms: [twitter, discord]
steps:
- action: analyze_mention
sentiment: true
intent: true
- action: generate_reply
tone: friendly
helpful: true
- action: send_reply
delay: 30 # 延迟30秒,更像真人
version: '3.8'
services:
openclaw:
image: openclaw/openclaw:latest
volumes:
- ./config:/config
- ./workflows:/workflows
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- GITHUB_TOKEN=${GITHUB_TOKEN}
restart: unless-stopped
scheduler:
image: openclaw/scheduler:latest
volumes:
- ./workflows:/workflows
depends_on:
- openclaw
monitoring:
metrics:
- workflow_execution_time
- success_rate
- api_calls_count
- cost_per_workflow
alerts:
- condition: "success_rate < 0.9"
action: send_notification
- condition: "cost_per_day > 50"
action: send_alert