OpenClaw v2026.2 対応 | 本稿は AI アシスタントに受動的ではなく能動的に動作させたいユーザーに適しています。
TL;DR: Cron スケジュールタスク:"cron": [{"id": "daily", "schedule": "0 9 * * *", "message": "..."}]。Webhook トリガー:POST /webhook/your-path。Gmail Pub/Sub でメールを自動処理。Heartbeat で能動的にチェック。設定例:毎日朝報 0 8 * * 1-5、CI 通知 webhook、メールフィルター gmail pub/sub。
自動化概要
自動化のタイプ
| タイプ | トリガー方式 | 適用シナリオ |
|---|---|---|
| Cron | スケジュールトリガー | 日次レポート、定期チェック |
| Webhook | HTTP リクエスト | 外部システム連携 |
| Gmail Pub/Sub | 新着メール | メール自動化 |
| Heartbeat | 周期チェック | 能動的リマインダー、提案 |
アーキテクチャ図
flowchart TB
subgraph Triggers["トリガーソース"]
CRON[Cron スケジュール]
WH[Webhook HTTP]
GM[Gmail Pub/Sub]
HB[Heartbeat]
end
subgraph Gateway["Gateway"]
SCHED[スケジューラー]
ROUTE[ルーター]
AGENT[Agent]
end
subgraph Actions["アクション"]
MSG[メッセージ送信]
EXEC[タスク実行]
NOTIF[通知送信]
end
CRON --> SCHED
WH --> ROUTE
GM --> ROUTE
HB --> SCHED
SCHED --> AGENT
ROUTE --> AGENT
AGENT --> MSG
AGENT --> EXEC
AGENT --> NOTIF
Cron スケジュールタスク
Cron 式
┌───────────── 分 (0 - 59)
│ ┌───────────── 時 (0 - 23)
│ │ ┌───────────── 日 (1 - 31)
│ │ │ ┌───────────── 月 (1 - 12)
│ │ │ │ ┌───────────── 曜日 (0 - 6, 0 = 日曜)
│ │ │ │ │
* * * * *
よく使う式
| 式 | 説明 |
|---|---|
0 9 * * * |
毎日 9:00 |
0 18 * * 1-5 |
平日 18:00 |
*/30 * * * * |
30 分ごと |
0 0 1 * * |
毎月 1 日 0:00 |
0 9,18 * * * |
毎日 9:00 と 18:00 |
0 9 * * 1 |
毎週月曜 9:00 |
Cron タスクの設定
{
"cron": [
{
"id": "daily-briefing",
"schedule": "0 9 * * *",
"session": "main",
"message": "今日のスケジュールとタスクをお願いします",
"enabled": true
},
{
"id": "weekly-summary",
"schedule": "0 18 * * 5",
"session": "main",
"message": "今週の仕事のまとめを生成してください",
"enabled": true
},
{
"id": "health-check",
"schedule": "*/15 * * * *",
"session": "main",
"message": "システム状態を確認し、異常があれば報告してください",
"enabled": true
}
]
}
Cron 設定項目
| フィールド | 型 | 説明 |
|---|---|---|
id |
string | タスクの一意識別子 |
schedule |
string | Cron 式 |
session |
string | 対象セッション |
message |
string | 送信するメッセージ |
enabled |
boolean | 有効/無効 |
timezone |
string | タイムゾーン(デフォルトはシステム) |
Cron タスクの管理
# すべてのタスクを一覧表示
openclaw cron list
# 出力例:
# ID Schedule Status Last Run
# daily-briefing 0 9 * * * enabled 2026-02-26 09:00
# weekly-summary 0 18 * * 5 enabled 2026-02-23 18:00
# health-check */15 * * * * enabled 2026-02-26 10:30
# タスクを手動実行
openclaw cron run daily-briefing
# タスクの有効化/無効化
openclaw cron enable daily-briefing
openclaw cron disable daily-briefing
# タスクログを表示
openclaw cron logs daily-briefing
Webhook トリガー
Webhook の設定
{
"webhooks": [
{
"id": "github-push",
"path": "/webhook/github",
"secret": "your-webhook-secret",
"session": "main",
"handler": "github-push"
},
{
"id": "custom-alert",
"path": "/webhook/alert",
"secret": "your-webhook-secret",
"session": "main",
"message": "アラート受信: {{data.message}}"
}
]
}
Webhook エンドポイント
POST http://your-gateway:18789/webhook/github-push
POST http://your-gateway:18789/webhook/alert
GitHub Webhook 例
{
"webhooks": [
{
"id": "github-push",
"path": "/webhook/github",
"secret": "${GITHUB_WEBHOOK_SECRET}",
"session": "work",
"handler": "github-push"
}
]
}
Handler スクリプト:
// ~/.openclaw/handlers/github-push.js
module.exports = async (payload, session) => {
if (payload.ref === 'refs/heads/main') {
const commits = payload.commits.map(c => c.message).join('\n- ');
return `新しいプッシュを検出しました:\n\nブランチ: main\nコミット:\n- ${commits}\n\n何かお手伝いしましょうか?`;
}
return null;
};
カスタム Webhook 処理
{
"webhooks": [
{
"id": "monitoring-alert",
"path": "/webhook/alert",
"methods": ["POST"],
"session": "main",
"message": "🚨 アラート通知\n\nレベル: {{data.level}}\nサービス: {{data.service}}\nメッセージ: {{data.message}}\n時刻: {{data.timestamp}}"
}
]
}
Webhook を送信:
curl -X POST http://localhost:18789/webhook/alert \
-H "Content-Type: application/json" \
-H "X-Webhook-Secret: your-secret" \
-d '{
"level": "critical",
"service": "api-server",
"message": "CPU 使用率が 90% を超えました",
"timestamp": "2026-02-26T10:30:00Z"
}'
Webhook セキュリティ
{
"webhooks": [
{
"id": "secure-webhook",
"path": "/webhook/secure",
"secret": "your-secret-key",
"signatureHeader": "X-Signature",
"signatureAlgorithm": "sha256",
"ipWhitelist": ["192.168.1.0/24"]
}
]
}
Gmail Pub/Sub 連携
Gmail Pub/Sub の設定
{
"gmail": {
"pubsub": {
"enabled": true,
"projectId": "your-project-id",
"subscription": "gmail-subscription",
"credentials": {
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "...",
"private_key": "...",
"client_email": "..."
},
"filters": [
{
"from": "[email protected]",
"session": "main",
"message": "重要メールを受信:\n差出人: {{sender}}\n件名: {{subject}}"
}
]
}
}
}
Gmail Pub/Sub のセットアップ
- Google Cloud プロジェクトを作成
- Gmail API を有効化
- Pub/Sub トピックを作成
- サービスアカウントを作成
- Gmail watch を設定
# Gmail watch を設定
openclaw gmail watch --email [email protected]
Gmail フィルター
| フィルター条件 | 説明 |
|---|---|
from |
差出人メールアドレス |
to |
宛先メールアドレス |
subject |
件名キーワード |
hasAttachment |
添付ファイルの有無 |
label |
Gmail ラベル |
{
"filters": [
{
"from": "[email protected]",
"session": "work",
"message": "GitHub 通知を受信: {{subject}}"
},
{
"from": "[email protected]",
"hasAttachment": true,
"session": "main",
"message": "Stripe ドキュメントを受信、処理してください"
}
]
}
Heartbeat 能動チェック
Heartbeat の設定
{
"heartbeat": {
"enabled": true,
"interval": 3600000,
"session": "main",
"message": "Heartbeat: 注目すべき事項がないか確認してください"
}
}
Heartbeat の用途
| 用途 | 説明 |
|---|---|
| 能動的リマインダー | 定期的にユーザーにリマインド |
| 状態チェック | システムやサービスの状態を確認 |
| タスク提案 | コンテキストに基づいて提案 |
| コンテキスト維持 | セッションをアクティブに保つ |
Heartbeat 例
{
"heartbeat": {
"enabled": true,
"interval": 1800000,
"conditions": [
{
"type": "time",
"start": "09:00",
"end": "18:00"
},
{
"type": "active",
"session": "main"
}
],
"message": "現在時刻に基づき、以下を確認することをお勧めします:\n1. 今日のタスク\n2. メールリマインダー\n3. スケジュール"
}
}
自動化実践例
例一:毎日朝報
{
"cron": [
{
"id": "morning-briefing",
"schedule": "0 8 * * 1-5",
"session": "main",
"message": "おはようございます!今日の朝報をお願いします:\n1. 天気予報\n2. 今日のスケジュール\n3. タスク\n4. 重要メールの要約"
}
]
}
例二:CI/CD 通知
{
"webhooks": [
{
"id": "ci-failure",
"path": "/webhook/ci",
"session": "dev",
"message": "⚠️ CI 失敗\n\nプロジェクト: {{data.repository}}\nブランチ: {{data.branch}}\nコミット: {{data.commit}}\nエラー: {{data.error}}\n\n分析をお手伝いしましょうか?"
}
]
}
例三:メール自動処理
{
"gmail": {
"pubsub": {
"filters": [
{
"from": "[email protected]",
"hasAttachment": true,
"session": "main",
"message": "請求書メールを受信、処理中...\n添付ファイルを財務フォルダに保存してください"
}
]
}
}
}
例四:システム監視
{
"cron": [
{
"id": "system-monitor",
"schedule": "*/5 * * * *",
"session": "main",
"message": "システム状態を確認",
"skills": ["system-monitor"]
}
]
}
トラブルシューティング
Cron タスクが実行されない
# タスクのステータスを確認
openclaw cron list
# ログを確認
openclaw logs --filter cron
# 手動実行でテスト
openclaw cron run task-id
Webhook が応答しない
# Webhook エンドポイントを確認
curl -X POST http://localhost:18789/webhook/test \
-H "Content-Type: application/json" \
-d '{"test": true}'
# ログを確認
openclaw logs --filter webhook
Gmail Pub/Sub が動作しない
# サブスクリプションのステータスを確認
openclaw gmail status
# 再設定
openclaw gmail setup
# 権限を確認
openclaw gmail check-permissions
まとめ
自動化により OpenClaw は受動的応答から能動的動作へ:
- Cron:スケジュールに従ってタスクを実行
- Webhook:外部イベントでトリガー
- Gmail Pub/Sub:メール自動化
- Heartbeat:能動的リマインダーと提案
更新履歴:
- 2026-02-26:初版公開
シリーズナビゲーション:
- ← 前の記事:モバイル対応
- → 次の記事:実践:個人ナレッジ管理アシスタントの構築