Comprehensive tutorial series for OpenClaw AI agent gateway
A step-by-step guide for transitioning your OpenClaw deployment from single-user to multi-user safely.
You have:
The risk: Without proper configuration, new users will see YOUR conversation history.
Before making changes, verify your current state:
# 1. Check current dmScope
grep -i "dmScope" ~/.openclaw/openclaw.json
# If missing or "main", you need to migrate
# 2. Check current sessions
openclaw sessions list
# Note: "main" session contains your history
# 3. Backup current config
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.backup
# 4. Backup session data
cp -r ~/.openclaw/agents/main/sessions ~/.openclaw/agents/main/sessions.backup
Edit ~/.openclaw/openclaw.json:
{
// CRITICAL: Add session isolation
session: {
dmScope: "per-channel-peer",
},
// Tighten access control during transition
channels: {
telegram: {
enabled: true,
dmPolicy: "pairing", // Require approval for new users
// Optional: Temporarily restrict to just you
// allowFrom: ["YOUR_TELEGRAM_USER_ID"],
},
},
}
openclaw doctor
# Expected output:
# ✓ Configuration valid
# ✓ Session isolation: per-channel-peer
# ✓ Telegram: pairing mode
openclaw gateway restart
Message your bot and verify:
# Check new session was created
openclaw sessions list
# Should show something like:
# agent:main:telegram:dm:YOUR_USER_ID
This step confirms users are actually isolated.
Option A: Use a second Telegram account
Option B: Use the CLI to simulate
# Create a test message as "fake user"
# (This is a thought experiment — verify in logs)
openclaw logs --follow
# In another terminal, message from your main account
# Look for session key in logs — should include your user ID
If you want to preserve your conversation history:
# Your old session was likely "main" or similar
# Your new session key is: agent:main:telegram:dm:YOUR_USER_ID
# Option 1: Rename the session file
cd ~/.openclaw/agents/main/sessions
# Find your old session UUID
cat sessions.json | jq '."main"'
# Returns: { "uuid": "abc123..." }
# Update sessions.json to map new key to old UUID
# (Manual edit required — backup first!)
# Option 2: Start fresh (recommended)
# Just accept that your history resets
# Old history is still in sessions.backup if needed
Once isolation is verified:
{
session: {
dmScope: "per-channel-peer",
},
channels: {
telegram: {
enabled: true,
dmPolicy: "pairing", // Approve users one by one
// Or for fully open:
// dmPolicy: "open",
// allowFrom: ["*"],
},
},
}
# Check for unexpected session sharing
openclaw sessions list
# Each user should have their own session key:
# agent:main:telegram:dm:user1_id
# agent:main:telegram:dm:user2_id
# ...
# NOT a single "main" session
openclaw logs --follow | grep -E "(session|Created|isolated)"
# Watch for:
# [session] Created: agent:main:telegram:dm:123456789
# [session] Loaded: agent:main:telegram:dm:987654321
# Red flag:
# [session] Loaded: main ← This means isolation failed!
Have a friend message your bot and ask:
If something goes wrong:
# 1. Stop gateway
openclaw gateway stop
# 2. Restore config backup
cp ~/.openclaw/openclaw.json.backup ~/.openclaw/openclaw.json
# 3. Restore sessions (if needed)
rm -rf ~/.openclaw/agents/main/sessions
cp -r ~/.openclaw/agents/main/sessions.backup ~/.openclaw/agents/main/sessions
# 4. Restart
openclaw gateway
Cause: Session key changed from main to agent:main:telegram:dm:YOUR_ID
Solutions:
sessions.jsonCause: dmScope not applied, or cached session
Fix:
# Verify config
grep -i "dmScope" ~/.openclaw/openclaw.json
# Must show: "per-channel-peer" (or stricter)
# Restart gateway
openclaw gateway restart
# Clear problematic session if needed
openclaw sessions clear "main"
Cause: Invalid JSON5 syntax
Fix:
# Validate config
openclaw doctor --verbose
# Common issues:
# - Missing comma after dmScope line
# - Typo in dmScope value
# - Unclosed braces
cp openclaw.json openclaw.json.backupcp -r sessions sessions.backupsession.dmScope: "per-channel-peer"dmPolicy: "pairing" during transitionopenclaw doctor| Day | Action |
|---|---|
| Day 1 | Backup, update config, test yourself |
| Day 2-3 | Test with 1-2 trusted users |
| Day 4-7 | Monitor logs, verify isolation |
| Day 7+ | Open to broader audience |
Now that you’ve migrated, learn about Security Patterns for ongoing protection →