This chapter is a step-by-step tutorial on how to build an openclaw plugin to communicate with a robot.
We drafted a prompt and asked Gemini3 to refine it for better alignment with AI coding tasks.
Here is the final prompt,
-
System Overviewdescribes the main components, as well as the top level data flow. -
File Structurespecifies the file structure, enabling the AI coder to produce code that populates this scaffold. -
The LLM Schemaprovides the skeleton for the critical codes, with detailed description of their workflow, so that the AI coder has no chance to deviate from the design. -
The Skill Mappingwrites the skill markdown files that the AI coder can copy and paste without any change. -
Transport Logic & WebRTC Setupdescribes the functionality and workflow for those non-critical codes. -
Testing & Simulationplans the unit testing scripts. -
The Checklist for the Coderis for the remaining instructions that are not discussed in the previous sections.
With this prompt, we used Qoder IDE with qwen3-coder-plus model to write the code.
-
Start the
websocket_servernodeFor
websocket-server.ts, you can choose one of the following two commands to start it,$ pwd /home/robot/.openclaw/nodes $ node websocket-server.ts $ npx tsx websocket-server.tsFor
websocket-server.py, you can run the following command to start it,$ pwd /home/robot/.openclaw/nodes $ python3 websocket_server.pyTo test if the websocket server runs successfully, start either
websocket-server.tsorwebsocket_server.py,then run the
test-websocket-client.js, using one of the following two commands,$ pwd /home/robot/.openclaw/nodes $ node test-websocket-client.js $ npx tsx test-websocket-client.js -
Install and build the openclaw gateway
To install and build the
robot-pluginpackage, we usepnpm, butnpmshould be functional too.$ pwd /home/robot/.openclaw/plugins/robot-plugin $ pnpm install WARN 2 deprecated subdependencies found: domexception@1.0.1, node-domexception@1.0.0 Packages: +1 + Progress: resolved 594, reused 494, downloaded 0, added 1, done ╭ Warning ─────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Ignored build scripts: esbuild@0.27.7, koffi@2.15.4, protobufjs@7.5.4, sharp@0.34.5, wrtc@0.4.7. │ │ Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts. │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ Done in 2.9s using pnpm v10.33.0 $ pnpm build > robot-plugin@1.0.0 build /home/robot/.openclaw/plugins/robot-plugin > tsup CLI Building entry: src/index.ts CLI Using tsconfig: tsconfig.json CLI tsup v8.5.1 CLI Using tsup config: /home/robot/.openclaw/plugins/robot-plugin/tsup.config.ts CLI Target: es2020 CLI Cleaning output folder CJS Build start CJS dist/index.cjs 6.92 KB CJS dist/index.cjs.map 10.08 KB CJS ⚡️ Build success in 10ms -
Start the openclaw gateway in CLI terminal
To start the openclaw gateway, don't run the command
systemctl --user start openclaw-gateway.service,instead, use
DEBUG=openclaw:* openclaw gateway runto start up the openclaw gateway in CLI terminal with debugging mode.$ pwd /home/robot/.openclaw/nodes $ DEBUG=openclaw:* openclaw gateway run -
Input a user query in openclaw gateway webchat
In Openclaw webchat, input
Please use "robot_action" to make the robot move forward,or, input
Ask the robot to move forward.then switch to the CLI terminal to double check if the related messages appeared in the openclaw gateway log,
in addition, switch to the CLI terminal to doublec check if the websocket server's log.






