Files
assistant/docs/TEST_STEPS.md
wangliang e093995368 feat: 增强 Agent 系统和完善项目结构
主要改进:
- Agent 增强: 订单查询、售后支持、客服路由等功能优化
- 新增语言检测和 Token 管理模块
- 改进 Chatwoot webhook 处理和用户标识
- MCP 服务器增强: 订单 MCP 和 Strapi MCP 功能扩展
- 新增商城客户端、知识库、缓存和同步模块
- 添加多语言提示词系统 (YAML)
- 完善项目结构: 整理文档、脚本和测试文件
- 新增调试和测试工具脚本

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 16:28:47 +08:00

111 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速验证步骤
## 1. 测试 Cookie 读取
在您的商城网站yehwang 域名下的任何页面打开浏览器控制台F12运行
```javascript
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(";").shift();
}
console.log("Token:", getCookie("token"));
```
**预期结果**:应该能看到您的 JWT Token。
---
## 2. 配置 Chatwoot Widget
`chatwoot-widget-integration.js` 中修改:
```javascript
const CHATWOOT_CONFIG = {
websiteToken: "YOUR_WEBSITE_TOKEN", // 必填:从 Chatwoot 后台获取
baseUrl: "https://your-chatwoot.com", // 必填:您的 Chatwoot URL
getUserInfo: function () {
// 如果用户信息也在其他地方,需要调整这里
const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
return {
email: userInfo.email || "user@example.com", // 用户邮箱
name: userInfo.name || "User", // 用户姓名
jwt_token: getCookie("token"), // 从 Cookie 读取
};
},
};
```
---
## 3. 引入脚本
在商城页面的 `</body>` 之前添加:
```html
<script src="/js/chatwoot-widget-integration.js"></script>
```
---
## 4. 验证 Token 是否同步
1. 打开商城页面(已登录状态)
2. 打开浏览器控制台
3. 等待 2 秒后,应该看到:
```
检测到 yehwang 域名,检查 Cookie...
=== 所有可访问的 Cookie ===
token: eyJ0eXAiOiJqd3QifQ.eyJzdWIi...
=== Token 状态 ===
Token 存在: true
Token 长度: xxx
```
4. 打开 Chatwoot 聊天窗口
5. 在 Chatwoot 后台查看该 Contact 的自定义属性
6. 应该能看到 `jwt_token` 字段
---
## 5. 测试订单查询
在 Chatwoot 聊天中输入:
```
我的订单 202071324 怎么样了?
```
**预期结果**AI 返回订单详情。
---
## 常见问题
### Q: Cookie 读取为空?
A: 检查 Cookie 设置:
- Domain: `.yehwang`
- Path: `/`
- SameSite: `Lax` 或 `None`
- **不要**设置 `HttpOnly`(否则 JavaScript 无法读取)
### Q: 获取到 Token 但 Chatwoot 没有同步?
A: 检查:
1. `getUserInfo()` 是否返回了 `email`(必需)
2. Chatwoot 控制台是否有错误
3. 刷新页面重新加载 Widget
### Q: 用户邮箱在哪里获取?
A: 如果邮箱不在 localStorage
- 方案 1: 从另一个 Cookie 读取
- 方案 2: 在登录时写入 localStorage
- 方案 3: 通过 API 获取
- 方案 4: 使用用户 ID 代替(修改后端支持)