前のページ

03. OpenClaw チャネル設定:Telegram から始める

本記事では Telegram を例に、OpenClaw チャネル設定の完全なフローを詳しく解説します。Bot 作成、認証設定、セキュリティポリシー、グループ設定、および WhatsApp、Discord など他のチャネルの設定方法をカバーし、お馴染みのチャットアプリで AI アシスタントと対話できるようサポートします。

OpenClaw v2026.2 対応 | OpenClaw のインストールが完了し、利用可能な Telegram Bot Token(無料で取得可能)があることを前提としています。

TL;DR: Telegram は最も設定が簡単なチャネルです:Bot 作成(@BotFather)、Token 取得、~/.openclaw/openclaw.json に設定、Gateway 起動。デフォルトで DM ペアリング保護が有効、グループでは @メンションが必要。WhatsApp(QR コードログイン)、Discord(Bot Token)、Slack の設定も解説。

なぜ Telegram から始めるのか?

チャネル比較

特性 Telegram WhatsApp Discord Slack iMessage
設定の難易度 ⭐ 簡単 ⭐⭐ 中程度 ⭐⭐ 中程度 ⭐⭐ 中程度 ⭐⭐⭐ 複雑
無料利用
Bot API ✅ 充実 ⚠️ 限定的 ✅ 充実 ✅ 充実 ⚠️ 限定的
グループ対応 ⚠️
ファイル対応 ✅ 2GB ✅ 100MB ✅ 25MB ✅ 1GB
国内利用 ⚠️ プロキシ必要 ⚠️ プロキシ必要 ⚠️ プロキシ必要
推奨度 ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐ ⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐

Telegram を選ぶ理由

  1. 設定が最も簡単:Bot を作成して Token を取得するだけ
  2. ドキュメントが最も充実:Telegram Bot API は業界のベンチマーク
  3. 機能が最も豊富:コマンド、ボタン、インラインクエリなどをサポート
  4. コミュニティが最も活発:問題解決策を見つけやすい

Telegram Bot の作成

ステップ 1:BotFather を見つける

  1. Telegram アプリを開く
  2. @BotFather(公式 Bot 管理ツール)を検索
  3. 会話を開始
sequenceDiagram
    participant U as あなた
    participant BF as BotFather
    participant TG as Telegram
    
    U->>BF: /newbot
    BF->>U: Bot 表示名を入力
    U->>BF: My OpenClaw Assistant
    BF->>U: Bot ユーザー名を入力(bot で終わること)
    U->>BF: myclaw_bot
    BF->>TG: Bot を作成
    TG-->>BF: Bot 作成成功
    BF->>U: API Token を返す

ステップ 2:新規 Bot を作成

BotFather でコマンドを送信:

/newbot

プロンプトに従って操作:

  1. Bot 表示名:例 My OpenClaw(スペース可)
  2. Bot ユーザー名:例 myclaw_botbot で終わること)

作成成功後、BotFather が返す内容:

Done! Congratulations on your new bot...

Use this token to access the HTTP API:
7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Keep your token secure...

⚠️ 重要:API Token は適切に保管してください。Bot を完全に制御する権限を持っています。

ステップ 3:Bot 情報の設定(オプション)

# BotFather で Bot のアバターを設定
/setuserpic
# Bot を選択し、画像をアップロード

# Bot の説明を設定
/setdescription
# Bot を選択し、説明文を入力

# Bot の概要を設定
/setabouttext
# Bot を選択し、概要文を入力

# Bot のコマンドを設定
/setcommands
# コマンドリストを入力、例:
# start - 使い始める
# help - ヘルプを表示
# status - 状態を確認

OpenClaw の設定

方式 A:環境変数(クイックテスト)

# 環境変数を設定
export TELEGRAM_BOT_TOKEN="7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# Gateway を起動
openclaw gateway

方式 B:設定ファイル(本番推奨)

~/.openclaw/openclaw.json を編集:

{
  "agent": {
    "model": "anthropic/claude-opus-4-6"
  },
  "channels": {
    "telegram": {
      "botToken": "7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  }
}

方式 C:CLI で設定

# 対話式設定
openclaw config set channels.telegram.botToken "7123456789:AAH..."

# または onboard ウィザードで
openclaw onboard

設定の検証

# 設定を確認
openclaw config get channels.telegram.botToken

# 診断を実行
openclaw doctor

# Gateway を起動(デバッグモード)
openclaw gateway --verbose

起動成功時、以下のようなログが表示されます:

[INFO] Gateway starting on port 18789
[INFO] Telegram channel connected
[INFO] Bot: @myclaw_bot
[INFO] Waiting for messages...

セキュリティ設定

DM ペアリング機構

デフォルトでは、OpenClaw は DM ペアリング機構dmPolicy: "pairing")を有効にしており、見知らぬ人があなたの Bot を悪用するのを防ぎます。

sequenceDiagram
    participant S as 見知らぬ人
    participant B as Bot
    participant G as Gateway
    participant O as あなた
    
    S->>B: メッセージ送信「こんにちは」
    B->>G: メッセージ到着
    G->>G: ペアリング状態を確認
    G-->>B: 未ペアリング、ペアリングコードを返す
    B-->>S: 「ペアリングしてください:コード ABC123」
    S->>O: ペアリングコードを伝える
    O->>G: openclaw pairing approve telegram ABC123
    G->>G: ホワイトリストに追加
    G-->>S: ペアリング成功、会話可能

DM ポリシーの設定

{
  "channels": {
    "telegram": {
      "botToken": "your_token",
      "dmPolicy": "pairing",
      "allowFrom": []
    }
  }
}
ポリシー 説明 リスクレベル
pairing 新規ユーザーはペアリングコードが必要 ⭐ 安全(デフォルト)
open 誰でもメッセージ送信可能 ⭐⭐⭐ 危険

ペアリングリクエストの管理

# ペアリング待ちリストを表示
openclaw pairing list

# 出力例:
# Channel    Code     User        Created
# telegram   ABC123   @stranger   2026-02-26 10:30:00

# ペアリングを承認
openclaw pairing approve telegram ABC123

# ペアリングを拒否
openclaw pairing reject telegram ABC123

# ペアリング済みユーザーを表示
openclaw pairing show telegram

ホワイトリストモード

特定のユーザーのみメッセージ送信を許可:

{
  "channels": {
    "telegram": {
      "botToken": "your_token",
      "dmPolicy": "open",
      "allowFrom": [123456789, 987654321]
    }
  }
}

💡 Telegram ユーザー ID の取得@userinfobot に任意のメッセージを送ると、数字 ID が返ってきます。

グループ設定

基本グループ設定

{
  "channels": {
    "telegram": {
      "botToken": "your_token",
      "groups": {
        "*": {
          "requireMention": true
        }
      }
    }
  }
}
設定項目 説明
"*" 全グループにマッチ
requireMention グループでは Bot を @メンションする必要あり

複数グループの個別設定

{
  "channels": {
    "telegram": {
      "botToken": "your_token",
      "groups": {
        "-100123456789": {
          "requireMention": false,
          "name": "仕事用グループ"
        },
        "-100987654321": {
          "requireMention": true,
          "name": "雑談グループ"
        },
        "*": {
          "requireMention": true
        }
      }
    }
  }
}

💡 グループ ID の取得:Bot をグループに追加後、グループで任意のメッセージを送信し、Gateway ログでグループ ID を確認できます。

グループに Bot を追加

  1. グループ設定で「メンバーを追加」をクリック
  2. Bot のユーザー名(例 @myclaw_bot)を検索
  3. 追加を選択
  4. (オプション)Bot を管理者にしてより多くの権限を付与

WhatsApp 設定

方式:QR コードログイン

WhatsApp は Web プロトコルを使用し、QR コードでバインドが必要です:

# ログインフローを起動
openclaw channels login whatsapp

# ターミナルに QR コードが表示
# スマートフォンの WhatsApp でスキャン:
# 設定 > リンクされたデバイス > デバイスをリンク > QR コードをスキャン
sequenceDiagram
    participant U as ユーザー
    participant C as CLI
    participant W as WhatsApp
    participant G as Gateway
    
    U->>C: openclaw channels login whatsapp
    C->>W: QR コードをリクエスト
    W-->>C: QR コードを返す
    C->>U: QR コードを表示
    U->>W: スマホでスキャン
    W-->>C: 認証成功
    C->>G: 認証情報を保存
    G-->>U: WhatsApp 接続完了

設定例

{
  "channels": {
    "whatsapp": {
      "allowFrom": ["+8613800138000"],
      "groups": {
        "*": {
          "requireMention": true
        }
      }
    }
  }
}

WhatsApp の制限

制限項目 説明
スマホオンライン 接続維持に WhatsApp スマホアプリのオンラインが必要
メッセージ遅延 数秒から数分の遅延の可能性
ファイルサイズ 最大 100MB
番号リスク 頻繁な使用で番号制限の可能性

Discord 設定

Discord Bot の作成

  1. Discord Developer Portal にアクセス
  2. 「New Application」をクリック
  3. 名前を入力(例 OpenClaw Assistant
  4. 「Bot」ページで「Add Bot」をクリック
  5. Token をコピー(Application ID ではない)

OAuth2 権限の設定

  1. 「OAuth2」>「URL Generator」に移動
  2. 以下の権限にチェック:
権限カテゴリ 具体的な権限
Bot Permissions
General Read Messages/View Channels
General Send Messages
General Send Messages in Threads
General Manage Messages
General Embed Links
General Attach Files
General Read Message History
Text Add Reactions
Text Use Slash Commands
  1. 生成された招待リンクをコピー
  2. ブラウザでリンクを開き、Bot をサーバーに招待

設定例

{
  "channels": {
    "discord": {
      "token": "MTk4NjIyNDgzNDc...",
      "guilds": {
        "*": {
          "requireMention": true
        }
      }
    }
  }
}

Discord 機能設定

{
  "channels": {
    "discord": {
      "token": "your_token",
      "commands": {
        "native": true,
        "text": true
      },
      "mediaMaxMb": 25
    }
  }
}
設定項目 説明
commands.native Discord ネイティブスラッシュコマンドを有効化
commands.text テキストコマンド(例 /help)を有効化
mediaMaxMb メディアファイルサイズ制限

Slack 設定

Slack App の作成

  1. Slack API にアクセス
  2. 「Create New App」をクリック
  3. 「From scratch」を選択
  4. App 名を入力し、ワークスペースを選択

OAuth 権限の設定

「OAuth & Permissions」ページで以下の Bot Token Scopes を追加:

app_mentions:read
channels:history
channels:read
chat:write
files:read
files:write
groups:history
groups:read
im:history
im:read
im:write
mpim:history
mpim:read
mpim:write
reactions:read
reactions:write
users:read

ワークスペースへのインストール

  1. 「Install to Workspace」をクリック
  2. 権限を承認
  3. Bot User OAuth Tokenxoxb- で始まる)をコピー

設定例

{
  "channels": {
    "slack": {
      "botToken": "xoxb-...",
      "appToken": "xapp-...",
      "signingSecret": "..."
    }
  }
}

Socket Mode の有効化(推奨)

  1. 「Socket Mode」ページで有効化
  2. App-Level Token を生成
  3. OpenClaw に設定:
{
  "channels": {
    "slack": {
      "botToken": "xoxb-...",
      "appToken": "xapp-...",
      "socketMode": true
    }
  }
}

複数チャネルの同時有効化

完全設定例

{
  "agent": {
    "model": "anthropic/claude-opus-4-6"
  },
  "gateway": {
    "port": 18789,
    "bind": "loopback"
  },
  "channels": {
    "telegram": {
      "botToken": "telegram_bot_token",
      "dmPolicy": "pairing",
      "groups": {
        "*": { "requireMention": true }
      }
    },
    "whatsapp": {
      "allowFrom": ["+8613800138000"]
    },
    "discord": {
      "token": "discord_token",
      "guilds": {
        "*": { "requireMention": true }
      }
    },
    "slack": {
      "botToken": "xoxb-...",
      "appToken": "xapp-..."
    }
  }
}

メッセージルーティング図

flowchart TB
    subgraph Users["ユーザー"]
        WA[WhatsApp ユーザー]
        TG[Telegram ユーザー]
        DC[Discord ユーザー]
        SL[Slack ユーザー]
    end
    
    subgraph Gateway["Gateway"]
        MR[Message Router]
        SM[Session Manager]
    end
    
    subgraph Agent["Pi Agent"]
        AI[AI コア]
        CTX[共有コンテキスト]
    end
    
    WA --> MR
    TG --> MR
    DC --> MR
    SL --> MR
    MR --> SM
    SM --> AI
    AI --> CTX

全チャネルが同じ Agent を共有し、コンテキストは一元管理されます。つまり:

  • Telegram で質問した内容を WhatsApp で続きを議論できる
  • 異なるチャネルのユーザーが同じ記憶を共有できる
  • 各チャネルで独立したセッション分離ポリシーを設定可能

セッション管理コマンド

全チャネル共通コマンド(チャットで送信):

コマンド 機能
/status セッション状態を表示 モデル、Token 使用量を表示
/new または /reset セッションをリセット コンテキストをクリア、新規会話開始
/compact コンテキストを圧縮 履歴を要約、Token を解放
/think <level> 思考レベルを設定 /think high
/verbose on/off 詳細出力のオン/オフ /verbose on
/usage off/tokens/full 使用量表示モード /usage full

トラブルシューティング

Telegram Bot が応答しない

症状:メッセージ送信後に返信がない

調査手順

# 1. Gateway の稼働を確認
curl http://127.0.0.1:18789/health

# 2. Bot Token を確認
openclaw config get channels.telegram.botToken

# 3. 詳細ログを確認
openclaw gateway --verbose

# 4. doctor で診断
openclaw doctor

よくある原因

エラーメッセージ 原因 解決策
401 Unauthorized Token が無効 Token を再取得
409 Conflict Webhook の競合 古い Webhook を削除
403 Forbidden Bot がブロック Telegram サポートに連絡
Connection refused Gateway が未起動 Gateway を起動

WhatsApp QR コードスキャン失敗

症状:スキャン後に失敗と表示

解決策

# QR コードを再生成
openclaw channels logout whatsapp
openclaw channels login whatsapp

# ネットワークを確認
ping web.whatsapp.com

# 認証情報キャッシュをクリア
rm -rf ~/.openclaw/credentials/whatsapp*

Discord Bot の権限不足

症状:サーバーで Bot が応答しない、または権限エラー

解決策

  1. Bot のロール権限を確認
  2. Bot がサーバーに招待されているか確認
  3. 正しい OAuth URL で Bot を再招待
# ログで権限エラーを確認
openclaw gateway --verbose 2>&1 | grep -i permission

設定が反映されない

症状:設定変更後に動作が変わらない

解決策

# 1. Gateway を再起動
openclaw gateway --restart

# 2. キャッシュをクリア
rm -rf ~/.openclaw/cache/*

# 3. 設定ファイルの構文を検証
cat ~/.openclaw/openclaw.json | jq .

# 4. 設定の優先順位を確認
openclaw config list

セキュリティベストプラクティス

1. Token のセキュリティ

# Token をバージョン管理にコミットしない
echo ".openclaw/" >> .gitignore

# 環境変数で機密情報を保存
export TELEGRAM_BOT_TOKEN="your_token"

# Token を定期的にローテーション(BotFather で)
# /revoke コマンドで Token を再生成可能

2. アクセス制御

{
  "channels": {
    "telegram": {
      "dmPolicy": "pairing",
      "allowFrom": [],
      "groups": {
        "*": { "requireMention": true }
      }
    }
  },
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "non-main"
      }
    }
  }
}

3. ログ監査

# 詳細ログを有効化
openclaw gateway --verbose

# セッション履歴を確認
openclaw sessions list
openclaw sessions show <session-id>

# コマンド実行を監査
grep "bash" ~/.openclaw/logs/gateway.log

次のステップ

おめでとうございます!最初のチャネル設定が完了しました。次は:

  1. 会話をテスト → 設定したチャネルでメッセージを送信
  2. Skills をインストール → AI の機能を拡張
  3. 複数チャネルを設定 → さらにチャネルを追加

本記事のまとめ

  • Telegram Bot の作成と設定を習得
  • DM ペアリングとグループ設定を理解
  • WhatsApp、Discord、Slack の設定方法を習得
  • 複数チャネルの同時有効化を理解
  • よくある問題の調査方法を習得

更新履歴

  • 2026-02-26:初版公開、OpenClaw v2026.2 ベース

シリーズナビゲーション