Skip to main content

Connect DuckyClaw to OpenClaw

1. Overviewโ€‹

DuckyClaw is an AI voice assistant firmware that runs on IoT devices. It connects to the OpenClaw Gateway via the ACP protocol (Agent Client Protocol, WebSocket-based) to enable real-time conversation with an AI Agent.

OpenClaw is an open-source AI Agent platform that can be deployed on Linux, macOS, or Windows. Its built-in Gateway service listens on port 18789 by default, and DuckyClaw connects to it over the local network (or the internet).

Connection architecture:

DuckyClaw (IoT device)
โ”‚ WebSocket (ACP protocol)
โ–ผ
OpenClaw Gateway (PC / server)
โ”‚
โ–ผ
AI Agent (LLM conversation)

2. Prerequisitesโ€‹

2.1 Softwareโ€‹

SoftwareDescriptionDownload
OpenClawAI Agent platform โ€” install on your PC or serverOfficial website
DuckyClaw firmware toolchainRequired to compile and flash DuckyClaw firmwareSee DuckyClaw Quick Start

2.2 Network requirementsโ€‹

  • LAN mode: DuckyClaw device and the PC running OpenClaw are on the same local network or Wi-Fi
  • Internet mode: OpenClaw is deployed on a server with a public IP address

2.3 DuckyClaw base setupโ€‹

Complete the DuckyClaw base setup (Wi-Fi, firmware flashing) before following this guide.


3. OpenClaw configuration file locationโ€‹

The core configuration file is openclaw.json. Its default path depends on the operating system:

OSConfig file path
Linux~/.openclaw/openclaw.json
macOS~/.openclaw/openclaw.json
WindowsC:\Users\<username>\.openclaw\openclaw.json
note

~ refers to the current user's home directory, e.g. /home/username (Linux) or /Users/username (macOS). On Windows replace <username> with your login name.

Quick-open the config folder:

Terminal:

xdg-open ~/.openclaw

File manager:

Open your file manager, press Ctrl+L, type ~/.openclaw, and press Enter.

tip

.openclaw is a hidden folder (starts with .). If you can't see it, press Ctrl+H in the file manager to show hidden files.


4. Modify the OpenClaw Gateway configurationโ€‹

4.1 Back up the config fileโ€‹

cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.backup

4.2 Edit the config fileโ€‹

Terminal:

nano ~/.openclaw/openclaw.json

File manager:

  1. Open the ~/.openclaw folder (see Section 3)
  2. Right-click openclaw.json โ†’ Open with Text Editor

4.3 Update the Gateway config sectionโ€‹

Find the gateway field and replace it with the following (leave all other settings unchanged):

{
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"auth": {
"mode": "token",
"token": "your_token_here"
},
"controlUi": {
"dangerouslyAllowHostHeaderOriginFallback": true,
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
},
"tailscale": {
"mode": "off",
"resetOnExit": false
}
}
}
warning

Keep the "token" field's existing value. Do not write your_token_here literally โ€” replace it with your actual token (see Section 5.2).

Field descriptions:

FieldDescription
"bind": "lan"Makes the Gateway listen on the LAN network interface instead of only 127.0.0.1 โ€” required for DuckyClaw to connect
dangerouslyAllowHostHeaderOriginFallback: trueAllows non-browser clients (e.g. IoT devices) to open WebSocket connections
allowInsecureAuth: trueAllows authentication without HTTPS (LAN scenario)
dangerouslyDisableDeviceAuth: trueDisables device-level secondary authentication; token-only auth

4.4 Restart the Gatewayโ€‹

openclaw gateway restart
note

If the openclaw command is not available, fully quit and relaunch the OpenClaw application.


5. Get the IP address and Tokenโ€‹

5.1 Get the LAN IP addressโ€‹

ip addr show | grep -E "inet " | awk '{print $2}' | cut -d'/' -f1 | grep -v "^127"

Or:

hostname -I
tip

Use the IP address on the same LAN segment as your DuckyClaw device (typically 192.168.x.x or 10.x.x.x). A wired connection is more stable than Wi-Fi.

5.2 Get the Gateway Tokenโ€‹

The Token is stored in openclaw.json under gateway.auth.token.

grep '"token"' ~/.openclaw/openclaw.json

5.3 Verify Gateway accessibilityโ€‹

Open a browser on a device on the same network as DuckyClaw and visit:

http://<your-LAN-IP>:18789/

Any HTTP response (even an error page) means the Gateway is listening on the LAN address. If the connection times out, check your firewall (see Section 7).


6. Configure DuckyClaw firmwareโ€‹

6.1 Create the config fileโ€‹

In the DuckyClaw project root directory, copy and rename the example file:

cp include/tuya_app_config_secrets.h.example include/tuya_app_config_secrets.h

6.2 Edit the config fileโ€‹

Open include/tuya_app_config_secrets.h and fill in the ACP Gateway macros:

/* openclaw gateway configuration */
#define OPENCLAW_GATEWAY_HOST "xxx.xxx.xxx.xxx" /* Replace with OpenClaw host LAN IP */
#define OPENCLAW_GATEWAY_PORT 18789
#define OPENCLAW_GATEWAY_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /* Replace with actual Token */
#define DUCKYCLAW_DEVICE_ID "duckyclaw-001" /* Device ID, customizable */

Field descriptions:

MacroDescription
OPENCLAW_GATEWAY_HOSTLAN IP of the machine running OpenClaw (from Section 5.1)
OPENCLAW_GATEWAY_PORTFixed at 18789, no change needed
OPENCLAW_GATEWAY_TOKENToken from Section 5.2
DUCKYCLAW_DEVICE_IDDevice name; use a unique identifier (e.g. MAC address)

6.3 Recompile and flashโ€‹

After saving the config, recompile the firmware and flash it to the DuckyClaw device.


7. Troubleshootingโ€‹

7.1 DuckyClaw cannot connectโ€‹

Error in device logLikely causeFix
acp tcp connect failedIP unreachable or port blockedCheck IP; check that port 18789 is allowed in the firewall
acp upgrade rejectedWebSocket handshake rejectedConfirm dangerouslyAllowHostHeaderOriginFallback: true is set and Gateway restarted
acp connect res ok=falseToken mismatchVerify openclaw.json Token matches firmware OPENCLAW_GATEWAY_TOKEN exactly
acp connect timeoutNetwork issue or Gateway not runningConfirm OpenClaw is running; visit http://<IP>:18789/ in a browser
acp dns resolve failedHostname cannot be resolvedUse an IP address instead of a hostname

7.2 Verify Gateway is bound to the LAN addressโ€‹

After editing and restarting:

netstat -tlnp | grep 18789
# or
ss -tlnp | grep 18789

If Local Address shows 0.0.0.0:18789, the Gateway is successfully bound to all interfaces including the LAN.

7.3 Open port 18789 in the firewallโ€‹

ufw:

sudo ufw allow 18789/tcp

firewalld:

sudo firewall-cmd --add-port=18789/tcp --permanent
sudo firewall-cmd --reload

7.4 Config changes not taking effectโ€‹

  • Confirm you edited the correct file (see Section 3 for the path)
  • Confirm you fully restarted the Gateway (not just refreshed the page): openclaw gateway restart
  • If still not working, fully quit and relaunch the OpenClaw application