configure-openclaw
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfigure OpenClaw
配置OpenClaw
Set up OpenClaw so OMC can wake external gateways — triggering automations, workflows, or AI agents — when hook events fire during Claude sessions.
OpenClaw is NOT a notification system. It sends structured instruction payloads to programmable HTTPS endpoints. This makes it ideal for triggering n8n workflows, custom AI agents, webhook automations, or any HTTPS-capable system.
设置OpenClaw,使OMC能够在Claude会话期间触发钩子事件时,唤醒外部网关——进而触发自动化流程、工作流或AI Agent。
OpenClaw并非通知系统。它会向可编程HTTPS端点发送结构化指令负载。这使其非常适合触发n8n工作流、自定义AI Agent、Webhook自动化或任何支持HTTPS的系统。
How This Skill Works
该Skill的工作方式
This is an interactive, natural-language configuration skill. Walk the user through setup by asking questions with AskUserQuestion. Write the result to .
~/.claude/omc_config.openclaw.json这是一个交互式的自然语言配置Skill。通过AskUserQuestion提问引导用户完成设置,并将结果写入。
~/.claude/omc_config.openclaw.jsonStep 1: Detect Existing Configuration
步骤1:检测现有配置
bash
CONFIG_FILE="${OMC_OPENCLAW_CONFIG:-$HOME/.claude/omc_config.openclaw.json}"
if [ -f "$CONFIG_FILE" ]; then
IS_ENABLED=$(jq -r '.enabled // false' "$CONFIG_FILE" 2>/dev/null)
GATEWAY_COUNT=$(jq -r '.gateways | keys | length' "$CONFIG_FILE" 2>/dev/null)
HOOK_COUNT=$(jq -r '[.hooks | to_entries[] | select(.value.enabled == true)] | length' "$CONFIG_FILE" 2>/dev/null)
if [ "$IS_ENABLED" = "true" ]; then
echo "EXISTING_CONFIG=true"
echo "GATEWAY_COUNT=$GATEWAY_COUNT"
echo "HOOK_COUNT=$HOOK_COUNT"
else
echo "EXISTING_CONFIG=false"
fi
else
echo "NO_CONFIG_FILE"
fiIf existing config is found, show the user what's currently configured and ask if they want to update or reconfigure.
bash
CONFIG_FILE="${OMC_OPENCLAW_CONFIG:-$HOME/.claude/omc_config.openclaw.json}"
if [ -f "$CONFIG_FILE" ]; then
IS_ENABLED=$(jq -r '.enabled // false' "$CONFIG_FILE" 2>/dev/null)
GATEWAY_COUNT=$(jq -r '.gateways | keys | length' "$CONFIG_FILE" 2>/dev/null)
HOOK_COUNT=$(jq -r '[.hooks | to_entries[] | select(.value.enabled == true)] | length' "$CONFIG_FILE" 2>/dev/null)
if [ "$IS_ENABLED" = "true" ]; then
echo "EXISTING_CONFIG=true"
echo "GATEWAY_COUNT=$GATEWAY_COUNT"
echo "HOOK_COUNT=$HOOK_COUNT"
else
echo "EXISTING_CONFIG=false"
fi
else
echo "NO_CONFIG_FILE"
fi如果检测到现有配置,向用户展示当前配置内容,并询问他们是否需要更新或重新配置。
Step 2: Collect Gateway URL
步骤2:收集网关URL
Use AskUserQuestion:
Question: "What is your OpenClaw gateway URL? (Must be HTTPS, e.g. https://my-gateway.example.com/wake)"
The user will type their URL in the "Other" field.
Validate the URL:
- Must start with
https:// - Must be a valid URL
- If invalid, explain the requirement and ask again
使用AskUserQuestion:
问题: "你的OpenClaw网关URL是什么?(必须为HTTPS,例如https://my-gateway.example.com/wake)"
用户将在“其他”字段中输入URL。
验证URL:
- 必须以开头
https:// - 必须是有效的URL
- 如果无效,说明要求并再次询问
Step 3: Collect Auth Header (Optional)
步骤3:收集认证头(可选)
Use AskUserQuestion:
Question: "Does your gateway require an Authorization header?"
Options:
- Yes, Bearer token - I'll provide a Bearer token (e.g., )
Bearer sk-... - Yes, custom header value - I'll type the full header value
- No auth required - The gateway is open or uses a different auth method
If user selects option 1 or 2, ask:
Question: "Paste your Authorization header value (e.g., )"
Bearer sk-mytoken123The user will type the value in the "Other" field.
使用AskUserQuestion:
问题: "你的网关是否需要Authorization头?"
选项:
- 是,Bearer令牌 - 我将提供Bearer令牌(例如)
Bearer sk-... - 是,自定义头值 - 我将输入完整的头值
- 无需认证 - 网关是公开的或使用其他认证方式
如果用户选择选项1或2,询问:
问题: "粘贴你的Authorization头值(例如)"
Bearer sk-mytoken123用户将在“其他”字段中输入该值。
Step 4: Configure Hook Events
步骤4:配置钩子事件
Use AskUserQuestion with multiSelect:
Question: "Which hook events should trigger your OpenClaw gateway?"
Options (multiSelect: true):
- session-start - When a new Claude session begins. Variables: ,
{{sessionId}},{{projectName}}{{projectPath}} - session-end - When a session ends. Variables: ,
{{contextSummary}},{{reason}}{{sessionId}} - stop - When Claude stops (idle/completion). Variables: ,
{{sessionId}}{{projectName}} - pre-tool-use - Before each tool call (high frequency). Variables: ,
{{toolName}}{{sessionId}} - post-tool-use - After each tool call (high frequency). Variables: ,
{{toolName}}{{sessionId}} - keyword-detector - On every prompt submission. Variables: ,
{{prompt}}{{sessionId}} - ask-user-question - When Claude needs user input. Variables: ,
{{question}}{{sessionId}}
Default selection: session-start, session-end, stop.
Note: pre-tool-use, post-tool-use, and keyword-detector fire very frequently. Only enable them if your gateway can handle the volume.
使用支持多选的AskUserQuestion:
问题: "哪些钩子事件应该触发你的OpenClaw网关?"
选项(多选:是):
- session-start - 当新的Claude会话开始时。变量:,
{{sessionId}},{{projectName}}{{projectPath}} - session-end - 当会话结束时。变量:,
{{contextSummary}},{{reason}}{{sessionId}} - stop - 当Claude停止(闲置/完成)时。变量:,
{{sessionId}}{{projectName}} - pre-tool-use - 在每次工具调用之前(高频率)。变量:,
{{toolName}}{{sessionId}} - post-tool-use - 在每次工具调用之后(高频率)。变量:,
{{toolName}}{{sessionId}} - keyword-detector - 在每次提交提示时。变量:,
{{prompt}}{{sessionId}} - ask-user-question - 当Claude需要用户输入时。变量:,
{{question}}{{sessionId}}
默认选择:session-start, session-end, stop。
注意: pre-tool-use、post-tool-use和keyword-detector的触发频率非常高。只有当你的网关能够处理该流量时才启用它们。
Step 5: Collect Instruction Templates
步骤5:收集指令模板
For each selected event, ask the user for an instruction template. Show the available template variables for that event type.
Use AskUserQuestion for each event:
Example for session-start:
Question: "Instruction template for events. Available variables: , , , "
session-start{{sessionId}}{{projectName}}{{projectPath}}{{timestamp}}Options:
- Use default - "Session started for project {{projectName}}"
- Custom - Enter my own instruction text
Example for session-end:
Question: "Instruction template for events. Available variables: , , , , "
session-end{{sessionId}}{{projectName}}{{contextSummary}}{{reason}}{{timestamp}}Options:
- Use default - "Session ended. Summary: {{contextSummary}}"
- Custom - Enter my own instruction text
Example for stop:
Question: "Instruction template for events. Available variables: , , , "
stop{{sessionId}}{{projectName}}{{projectPath}}{{timestamp}}Options:
- Use default - "Session stopping for project {{projectName}}"
- Custom - Enter my own instruction text
Example for pre-tool-use:
Question: "Instruction template for events. Available variables: , , , "
pre-tool-use{{toolName}}{{sessionId}}{{projectName}}{{timestamp}}Options:
- Use default - "Tool {{toolName}} about to be used"
- Custom - Enter my own instruction text
Example for post-tool-use:
Question: "Instruction template for events. Available variables: , , , "
post-tool-use{{toolName}}{{sessionId}}{{projectName}}{{timestamp}}Options:
- Use default - "Tool {{toolName}} completed"
- Custom - Enter my own instruction text
Example for keyword-detector:
Question: "Instruction template for events. Available variables: , , , "
keyword-detector{{prompt}}{{sessionId}}{{projectName}}{{timestamp}}Options:
- Use default - "Keyword detected: {{prompt}}"
- Custom - Enter my own instruction text
Example for ask-user-question:
Question: "Instruction template for events. Available variables: , , , "
ask-user-question{{question}}{{sessionId}}{{projectName}}{{timestamp}}Options:
- Use default - "User input requested: {{question}}"
- Custom - Enter my own instruction text
对于每个选中的事件,向用户询问指令模板。展示该事件类型可用的模板变量。
对每个事件使用AskUserQuestion:
session-start示例:
问题: "事件的指令模板。可用变量:, , , "
session-start{{sessionId}}{{projectName}}{{projectPath}}{{timestamp}}选项:
- 使用默认值 - "Session started for project {{projectName}}"
- 自定义 - 输入我自己的指令文本
session-end示例:
问题: "事件的指令模板。可用变量:, , , , "
session-end{{sessionId}}{{projectName}}{{contextSummary}}{{reason}}{{timestamp}}选项:
- 使用默认值 - "Session ended. Summary: {{contextSummary}}"
- 自定义 - 输入我自己的指令文本
stop示例:
问题: "事件的指令模板。可用变量:, , , "
stop{{sessionId}}{{projectName}}{{projectPath}}{{timestamp}}选项:
- 使用默认值 - "Session stopping for project {{projectName}}"
- 自定义 - 输入我自己的指令文本
pre-tool-use示例:
问题: "事件的指令模板。可用变量:, , , "
pre-tool-use{{toolName}}{{sessionId}}{{projectName}}{{timestamp}}选项:
- 使用默认值 - "Tool {{toolName}} about to be used"
- 自定义 - 输入我自己的指令文本
post-tool-use示例:
问题: "事件的指令模板。可用变量:, , , "
post-tool-use{{toolName}}{{sessionId}}{{projectName}}{{timestamp}}选项:
- 使用默认值 - "Tool {{toolName}} completed"
- 自定义 - 输入我自己的指令文本
keyword-detector示例:
问题: "事件的指令模板。可用变量:, , , "
keyword-detector{{prompt}}{{sessionId}}{{projectName}}{{timestamp}}选项:
- 使用默认值 - "Keyword detected: {{prompt}}"
- 自定义 - 输入我自己的指令文本
ask-user-question示例:
问题: "事件的指令模板。可用变量:, , , "
ask-user-question{{question}}{{sessionId}}{{projectName}}{{timestamp}}选项:
- 使用默认值 - "User input requested: {{question}}"
- 自定义 - 输入我自己的指令文本
Step 6: Write Configuration
步骤6:写入配置
Build and write the config to :
~/.claude/omc_config.openclaw.jsonbash
CONFIG_FILE="${OMC_OPENCLAW_CONFIG:-$HOME/.claude/omc_config.openclaw.json}"
mkdir -p "$(dirname "$CONFIG_FILE")"构建配置并写入:
~/.claude/omc_config.openclaw.jsonbash
CONFIG_FILE="${OMC_OPENCLAW_CONFIG:-$HOME/.claude/omc_config.openclaw.json}"
mkdir -p "$(dirname "$CONFIG_FILE")"GATEWAY_URL, AUTH_HEADER, and per-event instructions are collected from user
GATEWAY_URL, AUTH_HEADER, and per-event instructions are collected from user
SELECTED_EVENTS is the list of enabled hook events
SELECTED_EVENTS is the list of enabled hook events
Build the JSON using jq
Build the JSON using jq
Example: session-start and session-end selected, bearer auth
Example: session-start and session-end selected, bearer auth
jq -n
--arg gateway_url "$GATEWAY_URL"
--arg auth_header "$AUTH_HEADER"
--arg session_start_instruction "$SESSION_START_INSTRUCTION"
--arg session_end_instruction "$SESSION_END_INSTRUCTION"
--arg stop_instruction "$STOP_INSTRUCTION"
'{ enabled: true, gateways: { "my-gateway": { url: $gateway_url, headers: (if $auth_header != "" then {"Authorization": $auth_header} else {} end), method: "POST", timeout: 10000 } }, hooks: { "session-start": {gateway: "my-gateway", instruction: $session_start_instruction, enabled: true}, "session-end": {gateway: "my-gateway", instruction: $session_end_instruction, enabled: true}, "stop": {gateway: "my-gateway", instruction: $stop_instruction, enabled: true} } }' > "$CONFIG_FILE"
--arg gateway_url "$GATEWAY_URL"
--arg auth_header "$AUTH_HEADER"
--arg session_start_instruction "$SESSION_START_INSTRUCTION"
--arg session_end_instruction "$SESSION_END_INSTRUCTION"
--arg stop_instruction "$STOP_INSTRUCTION"
'{ enabled: true, gateways: { "my-gateway": { url: $gateway_url, headers: (if $auth_header != "" then {"Authorization": $auth_header} else {} end), method: "POST", timeout: 10000 } }, hooks: { "session-start": {gateway: "my-gateway", instruction: $session_start_instruction, enabled: true}, "session-end": {gateway: "my-gateway", instruction: $session_end_instruction, enabled: true}, "stop": {gateway: "my-gateway", instruction: $stop_instruction, enabled: true} } }' > "$CONFIG_FILE"
Adjust the hooks object to include only the events the user selected, with their chosen instructions.
---jq -n
--arg gateway_url "$GATEWAY_URL"
--arg auth_header "$AUTH_HEADER"
--arg session_start_instruction "$SESSION_START_INSTRUCTION"
--arg session_end_instruction "$SESSION_END_INSTRUCTION"
--arg stop_instruction "$STOP_INSTRUCTION"
'{ enabled: true, gateways: { "my-gateway": { url: $gateway_url, headers: (if $auth_header != "" then {"Authorization": $auth_header} else {} end), method: "POST", timeout: 10000 } }, hooks: { "session-start": {gateway: "my-gateway", instruction: $session_start_instruction, enabled: true}, "session-end": {gateway: "my-gateway", instruction: $session_end_instruction, enabled: true}, "stop": {gateway: "my-gateway", instruction: $stop_instruction, enabled: true} } }' > "$CONFIG_FILE"
--arg gateway_url "$GATEWAY_URL"
--arg auth_header "$AUTH_HEADER"
--arg session_start_instruction "$SESSION_START_INSTRUCTION"
--arg session_end_instruction "$SESSION_END_INSTRUCTION"
--arg stop_instruction "$STOP_INSTRUCTION"
'{ enabled: true, gateways: { "my-gateway": { url: $gateway_url, headers: (if $auth_header != "" then {"Authorization": $auth_header} else {} end), method: "POST", timeout: 10000 } }, hooks: { "session-start": {gateway: "my-gateway", instruction: $session_start_instruction, enabled: true}, "session-end": {gateway: "my-gateway", instruction: $session_end_instruction, enabled: true}, "stop": {gateway: "my-gateway", instruction: $stop_instruction, enabled: true} } }' > "$CONFIG_FILE"
调整hooks对象,仅包含用户选中的事件及其选择的指令。
---Step 7: Test the Gateway
步骤7:测试网关
After writing config, offer to send a test wake call:
Use AskUserQuestion:
Question: "Send a test wake call to your gateway to verify the connection?"
Options:
- Yes, test now (Recommended) - Send a test HTTP POST to the gateway
- No, I'll test later - Skip testing
If testing:
bash
GATEWAY_URL="USER_PROVIDED_URL"
AUTH_HEADER="USER_PROVIDED_AUTH_HEADER" # may be empty写入配置后,提供发送测试唤醒请求的选项:
使用AskUserQuestion:
问题: "发送测试唤醒请求到你的网关以验证连接?"
选项:
- 是,现在测试(推荐) - 发送测试HTTP POST请求到网关
- 否,我稍后测试 - 跳过测试
如果选择测试:
bash
GATEWAY_URL="USER_PROVIDED_URL"
AUTH_HEADER="USER_PROVIDED_AUTH_HEADER" # may be emptyBuild auth header arg
Build auth header arg
AUTH_ARG=""
if [ -n "$AUTH_HEADER" ]; then
AUTH_ARG="-H "Authorization: $AUTH_HEADER""
fi
RESPONSE=$(eval curl -s -w "\n%{http_code}"
-H "Content-Type: application/json"
$AUTH_ARG
-d '{"event":"session-start","instruction":"OpenClaw test wake from OMC configure wizard","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","context":{}}'
"$GATEWAY_URL")
-H "Content-Type: application/json"
$AUTH_ARG
-d '{"event":"session-start","instruction":"OpenClaw test wake from OMC configure wizard","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","context":{}}'
"$GATEWAY_URL")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "202" ] || [ "$HTTP_CODE" = "204" ]; then
echo "Test wake succeeded (HTTP $HTTP_CODE)!"
else
echo "Test wake failed (HTTP $HTTP_CODE):"
echo "$BODY"
fi
Report success or failure. Common issues:
- **401 Unauthorized**: Auth header is missing or incorrect
- **403 Forbidden**: Token does not have permission
- **404 Not Found**: Gateway URL path is incorrect
- **SSL error**: URL must be HTTPS with a valid certificate
- **Connection refused**: Gateway is not running or URL is wrong
---AUTH_ARG=""
if [ -n "$AUTH_HEADER" ]; then
AUTH_ARG="-H "Authorization: $AUTH_HEADER""
fi
RESPONSE=$(eval curl -s -w "\n%{http_code}"
-H "Content-Type: application/json"
$AUTH_ARG
-d '{"event":"session-start","instruction":"OpenClaw test wake from OMC configure wizard","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","context":{}}'
"$GATEWAY_URL")
-H "Content-Type: application/json"
$AUTH_ARG
-d '{"event":"session-start","instruction":"OpenClaw test wake from OMC configure wizard","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","context":{}}'
"$GATEWAY_URL")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "202" ] || [ "$HTTP_CODE" = "204" ]; then
echo "Test wake succeeded (HTTP $HTTP_CODE)!"
else
echo "Test wake failed (HTTP $HTTP_CODE):"
echo "$BODY"
fi
报告测试成功或失败。常见问题:
- **401 Unauthorized**:缺少或不正确的认证头
- **403 Forbidden**:令牌没有权限
- **404 Not Found**:网关URL路径不正确
- **SSL错误**:URL必须是带有有效证书的HTTPS
- **连接被拒绝**:网关未运行或URL错误
---Step 8: Confirm
步骤8:确认
Display the final configuration summary:
OpenClaw Gateway Configured!
Gateway: https://my-gateway.example.com/wake
Auth: Bearer *** (configured)
Events: session-start, session-end, stop
Config saved to: ~/.claude/omc_config.openclaw.json
To activate OpenClaw, use one of:
omc --openclaw (per-session flag)
export OMC_OPENCLAW=1 (environment variable)
Debug logging:
export OMC_OPENCLAW_DEBUG=1 (logs wake results to stderr)
Custom config path:
export OMC_OPENCLAW_CONFIG=/path/to/config.json
To reconfigure: /oh-my-claudecode:configure-openclaw显示最终配置摘要:
OpenClaw Gateway Configured!
Gateway: https://my-gateway.example.com/wake
Auth: Bearer *** (configured)
Events: session-start, session-end, stop
Config saved to: ~/.claude/omc_config.openclaw.json
To activate OpenClaw, use one of:
omc --openclaw (per-session flag)
export OMC_OPENCLAW=1 (environment variable)
Debug logging:
export OMC_OPENCLAW_DEBUG=1 (logs wake results to stderr)
Custom config path:
export OMC_OPENCLAW_CONFIG=/path/to/config.json
To reconfigure: /oh-my-claudecode:configure-openclawTemplate Variables Reference
模板变量参考
| Event | Available Variables |
|---|---|
| |
| |
| |
| |
| |
| |
| |
Unresolved variables (e.g., ) are left as-is in the instruction text.
{{unknown}}| 事件 | 可用变量 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
未解析的变量(例如)将在指令文本中保持原样。
{{unknown}}Environment Variable Alternative
环境变量替代方案
Users can skip this wizard entirely by setting env vars and writing the config manually:
bash
undefined用户可以完全跳过该向导,通过设置环境变量并手动编写配置:
bash
undefinedEnable OpenClaw
Enable OpenClaw
export OMC_OPENCLAW=1
export OMC_OPENCLAW=1
Optional: override config file path
Optional: override config file path
export OMC_OPENCLAW_CONFIG="$HOME/.claude/omc_config.openclaw.json"
export OMC_OPENCLAW_CONFIG="$HOME/.claude/omc_config.openclaw.json"
Optional: enable debug logging
Optional: enable debug logging
export OMC_OPENCLAW_DEBUG=1
The config file path defaults to `~/.claude/omc_config.openclaw.json`. Use `OMC_OPENCLAW_CONFIG` to override.export OMC_OPENCLAW_DEBUG=1
配置文件路径默认为`~/.claude/omc_config.openclaw.json`。使用`OMC_OPENCLAW_CONFIG`可以覆盖该路径。