WhatsApp 本地路由器:将 WhatsApp 连接至本地 HTTP 端点 - Openclaw Skills

作者:互联网

2026-04-17

AI教程

什么是 WhatsApp 本地路由器?

WhatsApp 本地路由器是一项专门的技能,旨在桥接 WhatsApp 消息传递与本地开发环境。它允许开发人员将来自 WhatsApp 的传入文本或图像数据直接传输到运行在 localhost:8080 的本地服务器。该技能是更广泛的 Openclaw Skills 生态系统的一部分,无需复杂的云基础设施即可实现 AI 驱动的消息传递工作流快速原型设计。

它将传入数据视为原始输入,确保处理逻辑或 QR 解码的高保真度。通过充当透明代理,它允许 AI 代理与现有的本地微服务交互,使其成为开发人员构建与移动消息平台接口的自定义自动化或内部工具的强大实用程序。

下载入口:https://github.com/openclaw/skills/tree/main/skills/olegqm/whatsapp-local-endpoints-router

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install whatsapp-local-endpoints-router

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 whatsapp-local-endpoints-router。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

WhatsApp 本地路由器 应用场景

  • 通过本地后端逻辑处理任意文本字符串。
  • 解码通过 WhatsApp 图像附件接收的二维码。
  • 使用本地 HTTP 服务器原型化 WhatsApp 机器人交互。
  • 将特定的 WhatsApp 输入路由到自定义处理脚本以获得实时反馈。
WhatsApp 本地路由器 工作原理
  1. 识别传入消息源是否处于 WhatsApp 上下文中。
  2. 根据输入类型确定适当的路由:QR 图像检测触发 /decode-qr 端点,而标准文本触发 /process 端点。
  3. 执行底层的 scripts/route_whatsapp.sh shell 脚本来处理网络请求。
  4. 捕获来自本地服务器的 JSON 响应,并将其直接镜像回 WhatsApp 用户。
  5. 当本地端点失败时,通过提供简明摘要和原始响应体来处理错误状态。

WhatsApp 本地路由器 配置指南

确保您的本地服务器运行在 8080 端口,并且您的工作区中有必要的脚本。此技能旨在与您存储库中的其他 Openclaw Skills 无缝协作。

# 确保脚本具有执行权限
chmod +x skills/whatsapp-local-router/scripts/route_whatsapp.sh

# 测试文本处理路由
bash skills/whatsapp-local-router/scripts/route_whatsapp.sh process "your-text-here"

# 测试图像解码路由
bash skills/whatsapp-local-router/scripts/route_whatsapp.sh decode "/path/to/qr-image.png"

WhatsApp 本地路由器 数据架构与分类体系

该技能遵循基于输入类型的严格路由模式来组织数据流:

输入类型 路由 参数名称 预期输出
纯文本 /process 文本字符串 原始 JSON 响应
QR 图像 /decode-qr 图像 (multipart) 解码后的 JSON 响应

它对所有本地 HTTP 请求使用 20 秒超时,以确保代理的响应能力和可靠性。

name: whatsapp-local-router
description: Route incoming WhatsApp content to local HTTP endpoints and return endpoint JSON directly to the user. Use when a WhatsApp message contains plain text/random symbols that should be sent to POST http://localhost:8080/process, or when a WhatsApp message contains a QR image that should be sent to POST http://localhost:8080/decode-qr.

WhatsApp Local Router

Overview

Handle two WhatsApp input types and mirror backend responses back to the user:

  • Text input → /process
  • QR image input → /decode-qr

Always send the endpoint response body back to the user with no extra formatting unless the user asks for explanation.

Workflow

  1. Confirm the message comes from WhatsApp context.
  2. Choose route:
    • If inbound includes an image attachment path (QR image expected), call decode route.
    • Otherwise treat user text as arbitrary string and call process route.
  3. Execute request with scripts/route_whatsapp.sh.
  4. Return stdout from the script directly to the user.
  5. If the endpoint returns an error or invalid JSON, return a short error summary and include raw response body.

Commands

Run from workspace root:

# Text -> /process
bash skills/whatsapp-local-router/scripts/route_whatsapp.sh process ""

# Image -> /decode-qr
bash skills/whatsapp-local-router/scripts/route_whatsapp.sh decode "/path/to/image.png"

Routing Rules

  • Preserve text exactly; do not sanitize, trim, or reinterpret symbols.
  • Use multipart field name image for QR decode uploads.
  • Timeout requests after 20 seconds.
  • If both text and image are present, prioritize image decode unless user explicitly asks to process text.
  • Keep response concise: send backend JSON as-is.

相关推荐