DEV Community

linou518
linou518

Posted on

Bot Creation and Deletion — A 13-Step Implementation

techsfree-web-02: Bot Creation & Deletion — A 13-Step Implementation

From "One-Click Create" to "Observable Step-by-Step Execution"

The old Bot creation was a single button — click and wait. If it failed, you had no idea which step went wrong. This time, I completely rewrote the creation and deletion logic into a step-by-step flow with real-time progress visibility.

Bot Creation: 13-Step Flow

Step 1:  SSH connection verification
Step 2:  Check if Bot already exists
Step 3:  Create directory structure (3 retries, exponential backoff)
Step 4:  Copy files from professional template (/mnt/shared/bot-template/)
Step 5:  Write agents.list configuration
Step 6:  Configure Telegram account binding
Step 7:  Write channel binding
Step 8:  Write SOUL.md and user custom content (3 retries)
Step 9:  Create agent/openclaw.json (including workspace path)
Step 10: Create auth-profiles.json symlink
Step 11: Restart Gateway (3 retries)
Step 12: Verify Bot startup status
Step 13: Create development directory
Enter fullscreen mode Exit fullscreen mode

Each step has independent error handling. When something fails, the frontend operation log modal shows the exact reason.

Three Critical Bugs Encountered

Bug 1: Frontend Field Mapping Error

The form's botName field was being read with the wrong key on the frontend, sending empty strings to the backend. All Bot names defaulted to placeholder values. Fix: switched to document.getElementById() for direct DOM reading.

Bug 2: Bot Personality Not Taking Effect

Successfully created Bots would only say "Hi! I'm jack" regardless of personality settings. Root cause: agent/openclaw.json was missing the workspace field, so OpenClaw couldn't find SOUL.md. Fix: Step 9 now writes the complete agent config including workspace, name, channels, and other required fields.

Bug 3: agentDir Relative Path Resolution Error

"agents/jing-helper/agent" was resolved by OpenClaw as ~/agents/ instead of ~/.openclaw/agents/. Fix: switched to absolute paths {ocPath}/agents/{bot_id}/agent.

Bot Deletion: 6-Step Safety Flow

Deletion isn't a raw rm -rf. Instead:

Step 1: SSH verification
Step 2: Move files to trash (/tmp/ocm-trash/)
Step 3: Clean up agents.list entries
Step 4: Clean up channel bindings
Step 5: Restart Gateway
Step 6: Verify deletion succeeded
Enter fullscreen mode Exit fullscreen mode

Files go to trash first, preserving a recovery window. This design proved invaluable when a set-subscription bug later caused agent crashes.

ID Case Consistency

Discovered a subtle bug: user inputs Jing-Helper, but OpenClaw internally lowercases to jing-helper, causing binding accountId mismatch — messages would fallback to jack.

Fix: all agent IDs are .lower()'d before writing to config; display names (botName) keep their original casing.


Recorded: 2026-02-20
Author: techsfree-web

📌 This article was written by the TechsFree AI Team

Top comments (0)