OpenClaw 接入微信,QQ,飞书的正确方法-周红伟
OpenClaw 接入微信OpenClaw原 Clawdbot是一个开源、本地优先的 AI 代理网关能让大模型在你的电脑/服务器上 7X24 小时运行支持直接操作电脑、浏览网页、执行命令还能无缝接入飞书、Telegram、Discord 等聊天平台。本章节我们将 OpenClaw 接入飞书实现消息推送、发图、收文件审批交互、数据同步等自动化场景。如果你还没安装 OpenClaw需要先安装使用 npm 命令全局安装npm install -g openclawlatest --registryhttps://registry.npmmirror.com或使用 pnpm 命令安装pnpm add -g openclawlatestOpenClaw 安装可以详细参考OpenClaw (Clawdbot) 教程。个人微信一键接入ClawBot 插件iOS 8.0.70前置条件微信版本iOS 8.0.70 及以上已部署并运行 OpenClaw 实例本地/服务器均可操作步骤打开微信 → 我 → 设置 → 插件。找到「ClawBot」卡片点击进入, 可以看到安装的命令提示。复制终端安装命令也可以直接执行这一步:npx -y tencent-weixin/openclaw-weixin-clilatest install在 OpenClaw 所在设备的终端执行该命令:命令执行后会生成二维码用微信扫码绑定:扫码成功后会显示连接成功并重启:访问 OpenClaw 的后台查看频道看到微信已经部署好了:绑定成功后即可在微信聊天窗口直接与 OpenClaw 对话:Windows 用户的问题Windows 用户如果使用 npx有可能会报错未找到 openclaw。原因是 npx 使用 Linux 的 which 命令检测 openclawWindows 没有 which所以会报未找到 openclaw解决办法是我们可以使用 openclaw 的插件命令安装openclaw plugins install tencent-weixin/openclaw-weixin启用插件openclaw config set plugins.entries.openclaw-weixin.enabled true二维码登录openclaw channels login --channel openclaw-weixin终端会出现一个二维码用手机微信扫码并确认授权。如果插件还安装不成功可以使用网友 百里凌涵 提供的脚本 cli.mjs并与 package.json 与 LICENSE 文件放在同一目录代码如下然后执行该脚本即可继续安装。node ./cli.mjs installcli.mjs 文件内容#!/usr/bin/env nodeimport { execSync, spawnSync } from node:child_process;const PLUGIN_SPEC tencent-weixin/openclaw-weixin;const CHANNEL_ID openclaw-weixin;// ── helpers ──────────────────────────────────────────────────────────────────function log(msg) {console.log(\x1b[36m[openclaw-weixin]\x1b[0m ${msg});}function error(msg) {console.error(\x1b[31m[openclaw-weixin]\x1b[0m ${msg});}function run(cmd, { silent true } {}) {const stdio silent ? [pipe, pipe, pipe] : inherit;const result spawnSync(cmd, { shell: true, stdio });if (result.status ! 0) {const err new Error(Command failed with exit code ${result.status}: ${cmd});err.stderr silent ? (result.stderr || ).toString() : ;throw err;}return silent ? (result.stdout || ).toString().trim() : ;}function which(bin) {try {return execSync(which ${bin}, { encoding: utf-8, stdio: [pipe, pipe, pipe] }).trim();} catch {return null;}}// ── commands ─────────────────────────────────────────────────────────────────function install() {// 1. Check openclaw is installed//if (!which(openclaw)) {// error(未找到 openclaw请先安装);// console.log( npm install -g openclaw);// console.log( 详见 https://docs.openclaw.ai/install);// process.exit(1);//}log(已找到本地安装的 openclaw);// 2. Install plugin via openclawlog(正在安装插件...);try {const installOut run(openclaw plugins install ${PLUGIN_SPEC});if (installOut) log(installOut);} catch (installErr) {if (installErr.stderr installErr.stderr.includes(already exists)) {log(检测到本地已安装正在更新...);try {const updateOut run(openclaw plugins update ${CHANNEL_ID});if (updateOut) log(updateOut);} catch (updateErr) {error(插件更新失败请手动执行);if (updateErr.stderr) console.error(updateErr.stderr);console.log( openclaw plugins update ${CHANNEL_ID});process.exit(1);}} else {error(插件安装失败请手动执行);if (installErr.stderr) console.error(installErr.stderr);console.log( openclaw plugins install ${PLUGIN_SPEC});process.exit(1);}}// 3. Login (interactive QR scan)log(插件就绪开始首次连接...);try {run(openclaw channels login --channel ${CHANNEL_ID}, { silent: false });} catch {console.log();error(首次连接未完成可稍后手动重试);console.log( openclaw channels login --channel ${CHANNEL_ID});}// 4. Restart gateway so it picks up the new accountlog(正在重启 OpenClaw Gateway...);try {run(openclaw gateway restart, { silent: false });} catch {error(重启失败可手动执行);console.log( openclaw gateway restart);}}function help() {console.log(用法: npx -y tencent-weixin/openclaw-weixin-cli 命令命令:install 安装微信插件并扫码连接help 显示帮助信息);}// ── main ─────────────────────────────────────────────────────────────────────const command process.argv[2];switch (command) {case install:install();break;case help:case --help:case -h:help();break;default:if (command) {error(未知命令: ${command});}help();process.exit(command ? 1 : 0);}package.json 文件package.json{name: tencent-weixin/openclaw-weixin-cli,version: 1.0.2,description: Lightweight installer for the OpenClaw Weixin channel plugin,license: MIT,author: Tencent,type: module,bin: {weixin-installer: ./cli.mjs},files: [cli.mjs],engines: {node: 22}}LICENSE 文件代码MIT License Copyright (c) 2026 Tencent Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.安装过程
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2484348.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!