# clawd-miniprogram **Repository Path**: bty1987/clawd-miniprogram ## Basic Information - **Project Name**: clawd-miniprogram - **Description**: clawd-miniprogram - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-18 - **Last Updated**: 2026-02-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Moltbot 微信小程序 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![WeChat](https://img.shields.io/badge/Platform-WeChat-brightgreen)](https://developers.weixin.qq.com/miniprogram/dev/framework/) 一个基于 **Moltbot Gateway** 的极简 AI 助手微信小程序,开箱即用,无需复杂配置。 ## ✨ 特性 - 🚀 **开箱即用** - Token 认证,无需企业注册 - 💬 **实时聊天** - WebSocket 长连接,流式响应 - 🔄 **自动重连** - 断线自动恢复,无需手动操作 - ⚙️ **灵活配置** - 支持自定义 Gateway URL 和 Token - 📱 **极简 UI** - 现代化设计,流畅体验 ## 🎯 快速开始 ### 1. 启动 ngrok(暴露本地 Gateway) ```bash # 使用提供的快速启动脚本 ./start-ngrok.sh # 或手动启动 ngrok http 18789 ``` 记下输出的公网地址,例如: ``` Forwarding: https://abc123.ngrok-free.app -> http://localhost:18789 ``` ### 2. 修改小程序配置 打开 `app.js`,修改 `globalData.gatewayUrl`: ```javascript globalData: { gatewayUrl: 'wss://abc123.ngrok-free.app', // 替换为你的 ngrok 地址 authToken: '06b3230027e9d48635c879bbdebdb9e2', // Gateway 的认证 Token // ... } ``` ### 3. 用微信开发者工具打开 1. 下载微信开发者工具:https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html 2. 导入项目,选择 `/root/clawd/projects/miniprogram-ai-assistant` 3. AppID 选择"测试号"或你自己的 AppID 4. 点击"编译" ### 4. 体验聊天 - 在聊天界面输入消息,点击发送 - 查看实时回复 ## 📁 项目结构 ``` moltbot-miniprogram/ ├── app.js # 小程序入口 ├── app.json # 小程序配置 ├── app.wxss # 全局样式 ├── sitemap.json # 索引配置 ├── project.config.json # 项目配置 ├── start-ngrok.sh # 快速启动脚本 ├── pages/ │ ├── index/ # 首页(聊天界面) │ │ ├── index.js │ │ ├── index.wxml │ │ ├── index.wxss │ │ └── index.json │ └── settings/ # 设置页 │ ├── settings.js │ ├── settings.wxml │ ├── settings.wxss │ └── settings.json └── utils/ ├── websocket.js # WebSocket 封装 └── config.js # 配置文件 ``` ## ⚙️ 配置说明 ### Gateway URL Moltbot Gateway 的 WebSocket 地址,格式:`wss://your-domain.com` **获取方法:** - 本地测试:使用 ngrok 暴露 `localhost:18789` - 生产环境:配置 Nginx 代理到 `http://localhost:18789` ### Auth Token Moltbot Gateway 的认证 Token,位于 `~/.clawdbot/moltbot.json`: ```json { "gateway": { "auth": { "token": "06b3230027e9d48635c879bbdebdb9e2" } } } ``` **查看方法:** ```bash grep '"token"' ~/.clawdbot/moltbot.json ``` ## 🔧 技术栈 - **前端**: 微信小程序原生 - **后端**: [Moltbot Gateway](https://github.com/moltbot/moltbot) - **通信**: WebSocket - **认证**: Token 认证 ## 📋 后续计划 ### Phase 2: 云服务器 + 域名 - [ ] 购买云服务器(阿里云/腾讯云) - [ ] 购买域名 - [ ] 配置 Nginx 代理 Gateway - [ ] 申请 SSL 证书 - [ ] 小程序配置白名单域名 ### Phase 3: 功能完善 - [ ] 语音输入(ASR) - [ ] 文件上传(图片/文档) - [ ] 自定义快捷指令 - [ ] 推送通知(订阅消息) - [ ] 历史记录本地存储 - [ ] 深色模式 ## ⚠️ 注意事项 ### ngrok 免费版限制 - 免费版地址会变化(需要定期更新配置) - 连接数限制 - **适合测试,不适合生产环境** ### 小程序域名限制 - 生产环境必须配置白名单域名 - 必须使用 WSS 协议(HTTPS) - 域名需要 ICP 备案 ### Moltbot Gateway - 确保服务正在运行 - 确保 WebSocket 端口(18789)可访问 - 确保 Token 配置正确 ## 🔍 问题排查 ### 连接失败 ```bash # 检查 ngrok 是否运行 ps aux | grep ngrok # 检查 Gateway 是否运行 moltbot gateway status # 查看 Gateway 日志 tail -f /tmp/moltbot/moltbot-*.log ``` ### 消息发送失败 - 检查 WebSocket 是否已连接 - 查看开发者工具 Console 日志 - 确认 Token 是否正确 ### 无法连接到 Gateway - 检查防火墙设置 - 检查 Nginx 配置(如有) - 确认端口 18789 是否开放 ## 🚀 Moltbot 命令参考 ```bash # 启动 Gateway moltbot gateway start # 停止 Gateway moltbot gateway stop # 重启 Gateway moltbot gateway restart # 查看状态 moltbot gateway status # 查看日志 tail -f /tmp/moltbot/moltbot-*.log ``` ## 📄 License MIT License - 详见 [LICENSE](LICENSE) 文件 ## 🙏 致谢 - [Moltbot](https://github.com/moltbot/moltbot) - 强大的 AI 助手框架 - [微信小程序](https://developers.weixin.qq.com/miniprogram/dev/framework/) - 微信官方小程序平台 ## 📞 联系方式 - 项目主页: [GitHub](https://github.com/your-username/moltbot-miniprogram) - 问题反馈: [Issues](https://github.com/your-username/moltbot-miniprogram/issues) --- **Made with ❤️ by Moltbot Community**