主要改进: - Agent 增强: 订单查询、售后支持、客服路由等功能优化 - 新增语言检测和 Token 管理模块 - 改进 Chatwoot webhook 处理和用户标识 - MCP 服务器增强: 订单 MCP 和 Strapi MCP 功能扩展 - 新增商城客户端、知识库、缓存和同步模块 - 添加多语言提示词系统 (YAML) - 完善项目结构: 整理文档、脚本和测试文件 - 新增调试和测试工具脚本 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
262 lines
8.9 KiB
HTML
262 lines
8.9 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>B2B AI 助手 - 简化测试</title>
|
||
<style>
|
||
body {
|
||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||
max-width: 1200px;
|
||
margin: 0 auto;
|
||
padding: 20px;
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
min-height: 100vh;
|
||
}
|
||
.container {
|
||
background: white;
|
||
border-radius: 10px;
|
||
padding: 40px;
|
||
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
|
||
}
|
||
h1 {
|
||
color: #333;
|
||
text-align: center;
|
||
margin-bottom: 10px;
|
||
}
|
||
.subtitle {
|
||
text-align: center;
|
||
color: #666;
|
||
margin-bottom: 30px;
|
||
}
|
||
.info-box {
|
||
background: #f8f9fa;
|
||
border-left: 4px solid #667eea;
|
||
padding: 15px 20px;
|
||
margin: 20px 0;
|
||
border-radius: 5px;
|
||
}
|
||
.info-box h3 {
|
||
margin-top: 0;
|
||
color: #667eea;
|
||
}
|
||
.test-questions {
|
||
background: #fff3cd;
|
||
border: 1px solid #ffc107;
|
||
padding: 20px;
|
||
border-radius: 5px;
|
||
margin: 20px 0;
|
||
}
|
||
.test-questions h3 {
|
||
margin-top: 0;
|
||
color: #856404;
|
||
}
|
||
.question-list {
|
||
list-style: none;
|
||
padding: 0;
|
||
}
|
||
.question-list li {
|
||
background: white;
|
||
margin: 10px 0;
|
||
padding: 12px 15px;
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
transition: all 0.3s;
|
||
border: 1px solid #ddd;
|
||
}
|
||
.question-list li:hover {
|
||
background: #667eea;
|
||
color: white;
|
||
transform: translateX(5px);
|
||
}
|
||
.status {
|
||
text-align: center;
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
margin: 20px 0;
|
||
font-weight: bold;
|
||
}
|
||
.status.online {
|
||
background: #d4edda;
|
||
color: #155724;
|
||
}
|
||
.instructions {
|
||
background: #e7f3ff;
|
||
border-left: 4px solid #2196F3;
|
||
padding: 15px 20px;
|
||
margin: 20px 0;
|
||
border-radius: 5px;
|
||
}
|
||
.instructions ol {
|
||
margin: 10px 0;
|
||
padding-left: 20px;
|
||
}
|
||
.instructions li {
|
||
margin: 8px 0;
|
||
line-height: 1.6;
|
||
}
|
||
.feature-list {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||
gap: 20px;
|
||
margin: 30px 0;
|
||
}
|
||
.feature-card {
|
||
background: #f8f9fa;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
text-align: center;
|
||
}
|
||
.feature-card h4 {
|
||
color: #667eea;
|
||
margin-bottom: 10px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<h1>🤖 B2B AI 智能客服助手</h1>
|
||
<p class="subtitle">简化测试页面 - Chatwoot 官方集成方式</p>
|
||
|
||
<div class="status online">
|
||
✅ 系统状态:使用官方标准集成
|
||
</div>
|
||
|
||
<div class="instructions">
|
||
<h3>📝 使用说明</h3>
|
||
<ol>
|
||
<li><strong>点击右下角的聊天图标</strong>打开 Chatwoot 对话窗口</li>
|
||
<li><strong>输入消息</strong>开始与 AI 对话</li>
|
||
<li><strong>或者</strong>点击下面的测试问题,复制后在聊天窗口粘贴发送</li>
|
||
<li><strong>查看 AI 如何理解和回答</strong>你的问题</li>
|
||
</ol>
|
||
</div>
|
||
|
||
<div class="test-questions">
|
||
<h3>💬 推荐测试问题</h3>
|
||
<p style="color: #666; margin-bottom: 15px;">点击以下问题复制到剪贴板,然后在聊天窗口粘贴(Ctrl+V)并发送:</p>
|
||
<ul class="question-list">
|
||
<li onclick="copyQuestion(this.textContent)">🕐 你们的营业时间是什么?</li>
|
||
<li onclick="copyQuestion(this.textContent)">📦 我的订单 202071324 怎么样了?</li>
|
||
<li onclick="copyQuestion(this.textContent)">🔍 查询订单 202071324</li>
|
||
<li onclick="copyQuestion(this.textContent)">📞 如何联系客服?</li>
|
||
<li onclick="copyQuestion(this.textContent)">🛍️ 我想退换货</li>
|
||
<li onclick="copyQuestion(this.textContent)">📦 订单 202071324 的物流信息</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<h3>🔧 技术栈</h3>
|
||
<ul>
|
||
<li><strong>前端:</strong>Chatwoot 客户支持平台(官方 Widget SDK)</li>
|
||
<li><strong>AI 引擎:</strong>LangGraph + 智谱 AI (GLM-4.5)</li>
|
||
<li><strong>知识库:</strong>Strapi CMS + MCP</li>
|
||
<li><strong>业务系统:</strong>Hyperf PHP API</li>
|
||
<li><strong>缓存:</strong>Redis</li>
|
||
<li><strong>容器:</strong>Docker Compose</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="feature-list">
|
||
<div class="feature-card">
|
||
<h4>🎯 智能意图识别</h4>
|
||
<p>自动识别客户需求并分类</p>
|
||
</div>
|
||
<div class="feature-card">
|
||
<h4>📚 知识库查询</h4>
|
||
<p>快速检索 FAQ 和政策文档</p>
|
||
</div>
|
||
<div class="feature-card">
|
||
<h4>📦 订单管理</h4>
|
||
<p>查询订单、售后等服务</p>
|
||
</div>
|
||
<div class="feature-card">
|
||
<h4>🔄 多轮对话</h4>
|
||
<p>支持上下文理解的连续对话</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<h3>📊 系统信息</h3>
|
||
<p><strong>Chatwoot 服务:</strong>http://localhost:3000</p>
|
||
<p><strong>Website Token:</strong>39PNCMvbMk3NvB7uaDNucc6o</p>
|
||
<p><strong>集成方式:</strong>Chatwoot 官方 SDK</p>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
function copyQuestion(text) {
|
||
// 移除表情符号
|
||
const cleanText = text.replace(/^[^\s]+\s*/, '');
|
||
navigator.clipboard.writeText(cleanText).then(() => {
|
||
alert('✅ 问题已复制到剪贴板!\n\n请在聊天窗口中按 Ctrl+V 粘贴并发送。');
|
||
}).catch(err => {
|
||
console.error('复制失败:', err);
|
||
alert('❌ 复制失败,请手动复制问题文本。');
|
||
});
|
||
}
|
||
|
||
// ==================== Cookie Token 读取 ====================
|
||
|
||
function getCookie(name) {
|
||
const value = `; ${document.cookie}`;
|
||
const parts = value.split(`; ${name}=`);
|
||
if (parts.length === 2) return parts.pop().split(";").shift();
|
||
return null;
|
||
}
|
||
|
||
// 页面加载时检查 Token
|
||
window.addEventListener('load', function() {
|
||
const token = getCookie('token');
|
||
if (token) {
|
||
console.log('✅ Token 已从 Cookie 读取');
|
||
console.log('Token 长度:', token.length);
|
||
} else {
|
||
console.warn('⚠️ 未找到 Token,订单查询功能可能无法使用');
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<!-- Chatwoot Widget - 官方集成方式 -->
|
||
<script>
|
||
(function(d,t) {
|
||
var BASE_URL="http://localhost:3000";
|
||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||
g.src=BASE_URL+"/packs/js/sdk.js";
|
||
g.async = true;
|
||
s.parentNode.insertBefore(g,s);
|
||
g.onload=function(){
|
||
window.chatwootSDK.run({
|
||
websiteToken: '39PNCMvbMk3NvB7uaDNucc6o',
|
||
baseUrl: BASE_URL
|
||
});
|
||
|
||
console.log('✅ Chatwoot Widget 已加载 (官方集成方式)');
|
||
console.log('Base URL:', BASE_URL);
|
||
console.log('Website Token: 39PNCMvbMk3NvB7uaDNucc6o');
|
||
|
||
// 设置用户信息(可选)
|
||
setTimeout(function() {
|
||
const token = getCookie('token');
|
||
if (token && window.$chatwoot) {
|
||
window.$chatwoot.setUser('user_' + Date.now(), {
|
||
email: 'user@example.com',
|
||
name: 'Website User',
|
||
phone_number: ''
|
||
});
|
||
|
||
console.log('✅ 用户信息已设置');
|
||
} else if (!token) {
|
||
console.warn('⚠️ 未找到 Token');
|
||
}
|
||
}, 2000);
|
||
}
|
||
g.onerror=function(){
|
||
console.error('❌ Chatwoot SDK 加载失败');
|
||
console.error('请确保 Chatwoot 运行在: ' + BASE_URL);
|
||
}
|
||
})(document,"script");
|
||
</script>
|
||
</body>
|
||
</html>
|