Module 02

OpenClaw Setup

من التثبيت إلى ربط Telegram و Discord و WhatsApp

🎯
الهدف من الموديول
في نهاية الموديول ده هيكون عندك Gateway شغال + بوت Telegram متصل + حساب WhatsApp مربوط بـ QR.
📦
التثبيت
4 طرق رسمية: Install Script, npm, Docker, From Source
⚙️
الإعداد
openclaw onboard + فهم config.yaml + الـ Gateway
🔗
الربط
Telegram + Discord + WhatsApp خطوة بخطوة
Module 02 — Section 1

System Requirements

المتطلبات الأساسية للنظام

الشرط التفاصيل الحالة
Node.js الإصدار 24.16+ أو 26.1+ (Node 26 هو الموصى بيه) ✓
API Key من أي provider (Anthropic، OpenAI، Google، إلخ) ✓
RAM 2 GB على الأقل (لو هتبني Docker image) ✓
Disk مساحة كافية للـ images والـ logs ✓
bash
# تحقق من نسخة Node.js
node --version

# المفروض يطلعلك حاجة زي v24.16.0 أو v26.1.0 أو أعلى
⚠️
لو Node.js مش متثبت أو قديم
macOS/Linux: استخدم nvm — Windows: حمل من الموقع الرسمي nodejs.org
Module 02 — Section 2

Installation Methods

4 طرق رسمية لتثبيت OpenClaw

🚀
Install Script (موصى بيه)
الأسهل — بيكشف النظام ويثبت كل حاجة تلقائياً
📦
npm Global
npm install -g openclaw@latest
🐳
Docker
بيئة معزولة — مفيد لو مش عايز تثبيت Node.js مباشرة
💻
From Source
للـ Developers — git clone + pnpm install + pnpm build
bash
# macOS / Linux — Install Script
curl -fsSL https://openclaw.ai/install.sh | bash

# Windows (PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex

# npm Global Install
npm install -g openclaw@latest

# Docker
git clone https://github.com/openclaw/openclaw.git
cd openclaw
export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest"
./scripts/docker/setup.sh
Module 02 — Section 3

Initial Configuration

openclaw onboard — الـ Onboarding Wizard

💡
أول أمر لازم تشغله
openclaw onboard — الـ wizard هيدخل معاك خطوة بخطوة
1️⃣
اختيار الـ Model Provider
Anthropic، OpenAI، Google، إلخ
2️⃣
إدخال API Key
هيطلب منك مفتاح الـ API
3️⃣
توليد Gateway Token
هي自动生成 token للـ dashboard
4️⃣
اختيار الـ Channels
Telegram، Discord، WhatsApp، إلخ
bash
# تشغيل الـ Onboarding Wizard
openclaw onboard --install-daemon

# Quick Start (الأسرع)
npx openclaw@latest

# Classic Wizard
openclaw onboard --classic

# Non-Interactive (للـ automation)
openclaw onboard --non-interactive --accept-risk --mode local \
  --auth-choice openai-api-key \
  --secret-input-mode ref \
  --gateway-auth token \
  --gateway-token-ref-env OPENCLAW_GATEWAY_TOKEN \
  --skip-channels \
  --no-install-daemon

# Baseline Setup (بدون Wizard)
openclaw setup --baseline
Module 02 — Section 4

config.yaml Explained

فهم ملف الإعدادات — JSON5 format

📁
مكان الـ Config
~/.openclaw/openclaw.json — OpenClaw بيستخدم JSON5 (JSON مع دعم comments)
json5
{
  // Gateway settings
  gateway: {
    mode: "local",
    bind: "loopback",
    port: 18789,
    auth: {
      mode: "token",
      token: "your-token-here"
    }
  },

  // Agent defaults
  agents: {
    defaults: {
      workspace: "~/.openclaw/workspace",
      model: {
        primary: "anthropic/claude-sonnet-4-6",
        fallbacks: ["openai/gpt-5.4"]
      },
      thinkingDefault: "high",
      timeoutSeconds: 1800,
      heartbeat: { every: "0m" }
    }
  },

  // Channels
  channels: {
    telegram: {
      enabled: true,
      botToken: "123:abc",
      dmPolicy: "pairing",
      groups: { "*": { requireMention: true } }
    },
    discord: {
      enabled: true,
      token: "your-discord-token"
    },
    whatsapp: {
      enabled: true,
      dmPolicy: "pairing",
      allowFrom: ["+155****0123"]
    }
  },

  // Session management
  session: {
    dmScope: "per-channel-peer",
    reset: { mode: "daily", atHour: 4, idleMinutes: 120 }
  }
}
🔄
Hot Reload
OpenClaw بيعمل watch على ملف الـ config — أي change بتتعمله بتتطبق تلقائياً من غير restart
Module 02 — Section 5

Starting the Gateway

تشغيل الـ Gateway وأوامر مفيدة

▶️
Foreground (مؤقت)
openclaw gateway --port 18789 --verbose — يفضل شغال لحد ما تضغط Ctrl+C
🔄
Daemon (خلفية)
openclaw gateway install — بيثبت LaunchAgent (macOS) أو systemd (Linux) أو Scheduled Task (Windows)
bash
# تشغيل مؤقت
openclaw gateway --port 18789 --verbose

# تشغيل في الخلفية (Daemon)
openclaw gateway install

# التحقق من التشغيل
openclaw gateway status

# فتح الـ Dashboard
openclaw dashboard
# أو افتح في المتصفح: http://127.0.0.1:18789

# أوامر مفيدة
openclaw gateway restart          # Restart
openclaw gateway stop            # Stop
openclaw gateway status --deep   # Status مفصل
openclaw logs --follow           # مشاهدة الـ logs مباشرة
Module 02 — Section 6

Telegram Bot Setup

إنشاء بوت Telegram وربطه بـ OpenClaw

1️⃣
إنشاء البوت في BotFather
افتح Telegram وابحث عن @BotFather — ابعت /newbot — اختار اسم و username (لازم ينتهي بـ bot)
2️⃣
ربط البوت بـ OpenClaw
openclaw channels add --channel telegram --token <bot-token>
3️⃣
الموافقة على أول DM
ابعت أي message للبوت — رجع للـ terminal وشغل openclaw pairing list telegram
bash
# ربط البوت بـ OpenClaw (الطريقة 1: CLI)
openclaw channels add --channel telegram --token <bot-token>

# الطريقة 2: تعديل الـ Config مباشرة
# أضف في ~/.openclaw/openclaw.json:
{
  channels: {
    telegram: {
      enabled: true,
      botToken: "123:abc",
      dmPolicy: "pairing",
      groups: { "*": { requireMention: true } }
    }
  }
}

# التحقق من القناة
openclaw channels status --probe

# الموافقة على الـ pairing
openclaw pairing list telegram
openclaw pairing approve telegram <CODE>
Module 02 — Section 7

Discord Bot Setup

إنشاء بوت Discord وربطه بـ OpenClaw

🔗
Discord Developer Portal
روح لـ discord.com/developers/applications — New Application — سمّيه — روح لتبويب Bot — Reset Token
1️⃣
تفعيل الـ Intents
Message Content Intent (مطلوب) + Server Members Intent (موصى بيه)
2️⃣
إضافة البوت لـ Server
OAuth2 → URL Generator — اختر scopes: bot + applications.commands
3️⃣
ربط البوت بـ OpenClaw
export DISCORD_BOT_TOKEN + openclaw config patch
bash
# ربط البوت بـ OpenClaw
export DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN"

cat > discord.patch.json5 <<'JSON5'
{
  channels: {
    discord: {
      enabled: true,
      token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" }
    }
  }
}
JSON5

openclaw config patch --file ./discord.patch.json5 --dry-run
openclaw config patch --file ./discord.patch.json5
openclaw gateway

# التحقق
openclaw channels status --probe
Module 02 — Section 8

WhatsApp QR Setup

ربط حساب WhatsApp عبر QR Code

1️⃣
تثبيت الـ Plugin
openclaw plugins install @openclaw/whatsapp
2️⃣
ربط الحساب (QR Login)
openclaw channels login --channel whatsapp — هيطلعلك QR code في الـ terminal
3️⃣
مسح الـ QR
WhatsApp → Settings → Linked Devices → Link a Device → امسح الـ QR
bash
# تثبيت الـ Plugin
openclaw plugins install @openclaw/whatsapp

# أو لو بتشغل من Docker
export OPENCLAW_EXTENSIONS=whatsapp
./scripts/docker/setup.sh

# ربط الحساب (QR Login)
openclaw channels login --channel whatsapp

# التحقق
openclaw channels status --probe

# تسجيل الخروج
openclaw channels logout --channel whatsapp
Module 02 — Section 9

Common Errors & Fixes

أخطاء شائعة وحلولها

❌
Gateway مش بيشتغل
openclaw doctor + openclaw doctor --fix + openclaw logs --follow
🔌
Port 18789 مستخدم
lsof -i :18789 — أو غير الـ port: openclaw gateway --port 19000
🤖
Telegram Bot مش بيرد
تأكد من الـ token + Gateway status + Privacy Mode + pairing approve
💬
Discord Bot مش بيشوف الرسائل
فعّل Message Content Intent + تأكد من الـ permissions + البوت موجود في الـ Server
🚨
WhatsApp QR مش بيشتغل
جرب تعمل logout و login تاني — شوف الـ logs
bash
# تشخيص المشاكل
openclaw doctor
openclaw doctor --fix
openclaw logs --follow

# Config Validation Error
openclaw config schema
openclaw doctor --fix

# Node.js Version قديم
node --version
# لو أقل من 24.16، حدّث Node.js
nvm install 26
nvm use 26
Module 02 — Section 10

Updating OpenClaw

طرق التحديث المتاحة

🔄
تحديث تلقائي (موصى بيه)
openclaw update
📦
تحديث يدوي عبر npm
npm install -g openclaw@latest --allow-scripts=openclaw
🐳
تحديث عبر Docker
docker compose pull openclaw-gateway openclaw-cli
💬
تحديث من الـ Chat
ابعت /update في الـ chat
bash
# التحديث التلقائي (موصى بيه)
openclaw update

# التحديث اليدوي عبر npm
openclaw gateway stop
npm install -g openclaw@latest --allow-scripts=openclaw
openclaw doctor --fix
openclaw gateway start
openclaw gateway status --deep

# التحديث عبر pnpm
openclaw gateway stop
pnpm add -g --allow-build=openclaw openclaw@latest
openclaw doctor --fix
openclaw gateway start

# التحديث عبر Docker
docker compose pull openclaw-gateway openclaw-cli
docker compose up -d openclaw-gateway

# اختيار قناة التحديث
openclaw update --channel beta
openclaw update --channel extended-stable
openclaw update --dry-run   # معاينة من غير تطبيق
Module 02 — Project

Hands-on Project

مشروع عملي — طبق اللي اتعلمته

🎯
المشروع: جهّز OpenClaw من الصفر
هتعمل setup كامل لـ OpenClaw وتربطه بـ Telegram و Discord و WhatsApp
📋
الخطوة 1: التثبيت
ثبت OpenClaw بالطريقة اللي تناسبك (Install Script أو npm أو Docker)
⚙️
الخطوة 2: الإعداد
شغل openclaw onboard — اختار Provider — أدخل API Key — اختر Channels
🚀
الخطوة 3: التشغيل
شغل الـ Gateway — افتح الـ Dashboard — تأكد إن كل حاجة شغالة
🔗
الخطوة 4: الربط
ربط Telegram Bot + Discord Bot + WhatsApp QR — اختبر كل قناة
💡
نصيحة
وثّق كل خطوة — صور الـ screenshots — احفظ الـ commands في note للرجوع ليها
Module 02 — Quick Reference

Quick Reference

كل الأوامر اللي محتاجها في مكان واحد

bash
# التثبيت
curl -fsSL https://openclaw.ai/install.sh | bash
npm install -g openclaw@latest

# Onboarding
openclaw onboard --install-daemon
openclaw setup --baseline

# Gateway
openclaw gateway status
openclaw gateway install
openclaw gateway restart
openclaw dashboard

# Telegram
openclaw channels add --channel telegram --token <token>
openclaw pairing list telegram
openclaw pairing approve telegram <CODE>

# Discord
openclaw channels add --channel discord --token <token>

# WhatsApp
openclaw plugins install @openclaw/whatsapp
openclaw channels login --channel whatsapp

# التشخيص
openclaw doctor
openclaw triage
openclaw status --all
openclaw channels status --probe
openclaw logs --follow

# التحديث
openclaw update
Module 02 — Quiz

Knowledge Check

اختبر معلوماتك — 5 أسئلة

Module 2 Quiz — اختبار الموديول الثاني

Question 1/5
Module 02 — Complete

الخطوة الجاية

في Module 3 هنتعلم نربط OpenClaw بـ Hermes Agent

🎓
مبروك! أكملت Module 2
دلوقتي عندك Gateway شغال + بوت Telegram متصل + حساب WhatsApp مربوط بـ QR
📚
Module 3
هنتعلم نربط OpenClaw بـ Hermes Agent — وهنشوف إزاي الـ Gateway والـ Agent بيتكاملوا مع بعض
🔧
مهارات جديدة
Deep dive into Hermes configuration, customizing workflows, and setting up your environment for production use
💡
نصيحة
راجع الـ Quick Reference قبل ما تبدأ Module 3 — واحفظ كل الأوامر اللي اتعلمتها
← → للتنقل