Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

坐席智能体系统(Agent System)

项目简介

坐席智能体系统是一个面向客服人员的服务辅助工具,旨在通过标准化与智能化手段,提升服务效率与质量。系统采用前后端分离架构,后端基于Spring Boot框架,前端使用Vue 3 + TypeScript + Vite技术栈,支持智能对话、流程编排、话术推荐等功能。

核心功能

  1. 用户认证与权限管理

    • JWT Token认证
    • 多角色权限控制(管理员、坐席、主管、运营)
    • 用户个性化配置(主题、数字人形象)
  2. 诉求类型管理

    • 分级分类管理
    • 快速检索和选择
    • 支持图标和颜色自定义
  3. 服务流程管理

    • 标准化流程编排
    • 流程步骤引导
    • 流程版本管理
  4. 智能话术辅助

    • 话术库管理
    • 一键复制使用
    • 智能搜索推荐
    • 个人收藏夹
    • 热门话术排行
  5. 会话管理

    • 多会话并行处理
    • 实时消息收发
    • 会话转接
    • 会话步骤跟踪
    • 会话历史记录
  6. 工单系统

    • 自动工单创建
    • 工单分配和跟踪
    • 工单状态管理
  7. 运营分析

    • 坐席绩效统计
    • 诉求类型分析
    • 满意度统计
    • 运营报表生成
  8. AI智能服务

    • 智能话术推荐
    • 意图识别
    • 会话摘要生成
    • 情感分析
    • 语音转文字
    • 数字人交互
    • 智能质检
  9. 系统配置管理

    • 首页配置管理(标题、Logo、入口配置)
    • 登录页配置管理(背景、标题、样式)
    • 系统参数配置
  10. 安全监控

    • 登录监控与异常检测
    • 登录日志记录(成功/失败、IP、设备类型)
    • 异常行为检测(多次失败、异地登录)
  11. 知识库管理

    • 知识文档管理(增删改查)
    • 知识分类和标签
    • 智能搜索(标题、内容、关键词)
  12. 客户管理

    • 客户基本信息管理
    • 客户画像(VIP等级、消费金额、服务次数)
    • 风险评估(基于投诉、满意度等)
  13. 反馈管理

    • 多维度满意度评价
    • 评价统计分析
    • 需要跟进的反馈管理
  14. 高频问题分析

    • 自动记录高频问题
    • 问题去重和热度统计
    • 关联标准答案、话术、知识库
  15. 服务质量监控

    • 坐席质量评分(满意度、响应速度、服务量)
    • 实时质量指标监控
    • 会话质量检查
  16. 前端功能

    • 响应式用户界面
    • 智能卡片消息系统
    • 流程可视化编辑器
    • 实时聊天界面
    • 数据可视化图表
    • 知识学习模块
    • 工作台集成

技术栈

后端技术栈

  • 后端框架: Spring Boot 3.2.0
  • 编程语言: Java 17
  • 数据库: MySQL 8.0+
  • 缓存: Redis
  • 认证: Spring Security + JWT
  • ORM: Spring Data JPA (Hibernate)
  • 实时通信: WebSocket (STOMP)
  • API文档: Swagger/OpenAPI 3.0
  • 构建工具: Maven
  • JSON处理: FastJSON
  • HTTP客户端: OkHttp3
  • AI集成: OpenAI API Client, DashScope SDK

前端技术栈

  • 框架: Vue 3
  • 语言: TypeScript
  • 构建工具: Vite
  • UI库: Ant Design
  • 样式: Tailwind CSS
  • 动画: Framer Motion
  • 图表: Recharts
  • 状态管理: Zustand
  • HTTP客户端: Axios
  • 路由: React Router v6
  • 工具库: dayjs, ahooks

项目结构

agent-system/
├── frontend/                          # 前端项目
│   ├── src/
│   │   ├── api/                      # API 接口
│   │   ├── assets/                   # 资源文件
│   │   ├── components/               # 公共组件
│   │   │   ├── CardMessage/          # 卡片消息组件
│   │   │   ├── Loading/              # 加载组件
│   │   │   ├── EmptyState/           # 空状态组件
│   │   │   ├── PageHeader/           # 页面头部
│   │   │   ├── AnimatedCard/         # 动画卡片
│   │   │   ├── StatCard/             # 统计卡片
│   │   │   ├── ChatMessage/          # 聊天消息
│   │   │   ├── ScriptCard/           # 话术卡片
│   │   │   ├── ProcessStep/          # 流程步骤
│   │   │   └── SessionCard/          # 会话卡片
│   │   ├── layouts/                  # 布局组件
│   │   ├── pages/                    # 页面组件
│   │   │   ├── Login/                # 登录页
│   │   │   ├── Workbench/            # 工作台
│   │   │   ├── Analytics/            # 数据分析
│   │   │   ├── FlowEditor/           # 流程编辑
│   │   │   ├── FlowViewer/           # 流程查看
│   │   │   ├── Knowledge/            # 知识库
│   │   │   ├── KnowledgeLearning/    # 知识学习
│   │   │   ├── ProcessManagement/    # 流程管理
│   │   │   ├── ScriptManagement/     # 话术管理
│   │   │   ├── SystemManagement/     # 系统管理
│   │   │   ├── Settings/             # 系统设置
│   │   │   └── NotFound/             # 404页面
│   │   ├── store/                    # 状态管理
│   │   ├── utils/                    # 工具函数
│   │   ├── App.tsx                   # 根组件
│   │   └── main.tsx                  # 入口文件
│   ├── public/                       # 静态资源
│   ├── package.json                  # 依赖配置
│   └── vite.config.ts                # Vite配置
├── src/
│   ├── main/
│   │   ├── java/com/study/
│   │   │   ├── config/               # 配置类
│   │   │   ├── controller/           # 控制器层
│   │   │   ├── converter/            # 类型转换器
│   │   │   ├── dto/                  # 数据传输对象
│   │   │   ├── entity/               # 实体类
│   │   │   ├── enums/                # 枚举类
│   │   │   ├── exception/            # 异常处理
│   │   │   ├── repository/           # 数据访问层
│   │   │   ├── security/             # 安全相关
│   │   │   ├── service/              # 业务逻辑层
│   │   │   ├── util/                 # 工具类
│   │   │   ├── websocket/            # WebSocket
│   │   │   └── AgentSystemApplication.java
│   │   └── resources/
│   │       ├── application.yml       # 主配置文件
│   │       ├── application-dev.yml   # 开发环境配置
│   │       └── application-prod.yml  # 生产环境配置
│   └── test/                         # 测试代码
├── Dockerfile                        # Docker配置
├── docker-compose.yml                # Docker Compose配置
├── pom.xml                           # Maven配置
└── README.md                         # 项目说明

快速开始

1. 环境要求

  • JDK 17+
  • MySQL 8.0+
  • Redis 6.0+
  • Maven 3.6+
  • Node.js 16+
  • npm 8+

2. 数据库配置

创建数据库:

CREATE DATABASE agent_system CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

执行初始化脚本(可选):

mysql -u root -p agent_system < init.sql

3. 修改配置

编辑 src/main/resources/application.yml

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/agent_system
    username: your_username
    password: your_password

  data:
    redis:
      host: localhost
      port: 6379

4. 启动项目

# 使用Maven启动后端
mvn spring-boot:run

# 或者先打包再运行
mvn clean package
java -jar target/agent-1.0-SNAPSHOT.jar

启动前端(在frontend目录下):

cd frontend
npm install
npm run dev

5. 访问应用

API接口说明

认证模块

  • POST /auth/login - 用户登录
  • POST /auth/register - 用户注册
  • GET /auth/current - 获取当前用户信息
  • PUT /auth/profile - 更新用户信息
  • POST /auth/change-password - 修改密码
  • POST /auth/logout - 退出登录
  • POST /auth/avatar - 上传用户头像

诉求类型管理

  • GET /request-types - 获取所有诉求类型
  • GET /request-types/active - 获取启用的诉求类型
  • GET /request-types/parent/{parentId} - 根据父级ID获取诉求类型
  • POST /request-types - 创建诉求类型
  • PUT /request-types/{id} - 更新诉求类型
  • DELETE /request-types/{id} - 删除诉求类型

服务流程管理

  • GET /flows - 获取所有流程
  • GET /flows/request-type/{requestTypeId} - 根据诉求类型获取流程
  • GET /flows/request-type/{requestTypeId}/default - 获取默认流程
  • GET /flows/{id} - 根据ID获取流程
  • GET /flows/{id}/steps - 获取流程步骤
  • POST /flows - 创建流程
  • PUT /flows/{id} - 更新流程
  • DELETE /flows/{id} - 删除流程
  • POST /flows/steps - 创建流程步骤
  • PUT /flows/steps/{id} - 更新流程步骤
  • DELETE /flows/steps/{id} - 删除流程步骤
  • PUT /flows/{flowId}/steps/order - 批量更新流程步骤顺序
  • PUT /flows/{flowId}/steps/{stepId}/move - 移动流程步骤位置
  • POST /flows/steps/{stepId}/duplicate - 复制流程步骤

话术管理

  • GET /scripts - 获取所有公开话术
  • GET /scripts/{id} - 根据ID获取话术
  • GET /scripts/request-type/{requestTypeId} - 根据诉求类型获取话术
  • GET /scripts/flow-step/{flowStepId} - 根据流程步骤获取话术
  • GET /scripts/category/{category} - 根据分类获取话术
  • GET /scripts/categories - 获取所有话术分类
  • GET /scripts/search - 搜索话术(智能推荐)
  • GET /scripts/autocomplete - 实时话术联想
  • GET /scripts/smart-autocomplete - 智能自动补全
  • GET /scripts/popular - 获取热门话术
  • GET /scripts/with-summary - 获取话术列表(带摘要)
  • GET /scripts/{id}/summary - 获取话术摘要
  • POST /scripts/{id}/use - 使用话术(增加计数)
  • GET /scripts/favorites - 获取我的收藏
  • GET /scripts/favorites/details - 获取收藏夹详情
  • GET /scripts/favorites/by-tags - 按标签分类获取收藏夹
  • GET /scripts/favorites/frequently-used - 获取高频使用的收藏话术
  • GET /scripts/favorites/search - 搜索收藏夹中的话术
  • POST /scripts/favorites - 添加收藏
  • DELETE /scripts/favorites/{scriptId} - 取消收藏
  • PUT /scripts/favorites/{id} - 更新收藏
  • POST /scripts - 创建话术
  • PUT /scripts/{id} - 更新话术
  • DELETE /scripts/{id} - 删除话术
  • POST /scripts/templates/update - 手动触发话术模板更新
  • POST /scripts/generate-contextual - 生成上下文化话术
  • POST /scripts/templates/{id}/variants - 批量生成话术变体
  • GET /scripts/smart-recommend - 智能推荐话术
  • POST /scripts/ai-generate - 使用AI生成全新话术
  • POST /scripts/{id}/ai-optimize - 使用AI优化现有话术
  • POST /scripts/ai-test - 测试AI话术生成

会话管理

  • GET /sessions/my - 获取我的会话列表
  • GET /sessions/my/active - 获取活动会话
  • GET /sessions/my/multi-session-overview - 获取多会话概览
  • POST /sessions/{id}/switch - 切换当前工作会话
  • POST /sessions - 创建会话
  • PUT /sessions/{id} - 更新会话
  • POST /sessions/{id}/messages - 发送消息
  • GET /sessions/{id}/unread-count - 获取未读消息数
  • POST /sessions/{id}/evaluation - 提交会话评价
  • GET /sessions/{id}/customer-info - 获取当前会话客户信息
  • POST /sessions/{id}/select-request-type - 选择诉求类型
  • GET /sessions/request-type/{requestTypeId}/matched - 获取诉求类型匹配的流程和话术
  • PUT /sessions/{id}/request-type - 更新会话诉求类型
  • GET /sessions/{id}/request-type-switch-history - 获取诉求类型切换历史
  • GET /sessions/{id}/flow-steps - 获取会话的服务流程步骤
  • GET /sessions/{id}/script-recommendations - 获取会话的话术推荐
  • GET /sessions/{id}/smart-script-recommendations - 获取智能话术推荐
  • GET /sessions/flow-step/{flowStepId}/scripts - 获取流程步骤的话术列表
  • POST /sessions/{id}/move-to-next-step - 移动到下一步
  • POST /sessions/{id}/move-to-previous-step - 移动到上一步
  • POST /sessions/{id}/move-to-step - 移动到指定步骤
  • GET /sessions/{id}/emotion-analysis - 获取会话情绪分析概览
  • POST /sessions/{id}/transfer - 转接会话
  • POST /sessions/{id}/close - 结束会话
  • POST /sessions/messages/{messageId}/read - 标记消息已读

工单管理

  • GET /work-orders/my - 获取我的工单
  • GET /work-orders/{id} - 根据ID获取工单
  • GET /work-orders/session/{sessionId} - 根据会话ID获取工单
  • POST /work-orders - 创建工单
  • PUT /work-orders/{id} - 更新工单
  • POST /work-orders/{id}/assign - 分配工单
  • POST /work-orders/{id}/resolve - 解决工单
  • POST /work-orders/{id}/close - 关闭工单
  • POST /work-orders/{id}/cancel - 取消工单
  • DELETE /work-orders/{id} - 删除工单
  • POST /work-orders/auto-create/{sessionId} - 自动创建工单
  • GET /work-orders/{id}/tracking - 获取工单跟踪信息

AI智能服务

  • POST /ai/suggest-scripts - 智能话术建议
  • POST /ai/analyze-intent - 意图识别
  • POST /ai/generate-summary - 生成会话摘要
  • POST /ai/speech-to-text - 语音转文字
  • POST /ai/digital-avatar - 数字人交互

数据分析

  • GET /analytics/my-statistics - 获取个人统计数据
  • GET /analytics/request-types - 获取诉求类型统计
  • GET /analytics/overview - 获取系统概览
  • GET /analytics/top-request-types - 获取热门诉求类型排行
  • GET /analytics/agent-ranking - 获取坐席排行榜
  • GET /analytics/operation-report - 生成运营报表
  • GET /analytics/agent-service-time - 获取各坐席服务时间统计
  • GET /analytics/agent-call-volume - 获取各坐席通话量统计

系统配置管理

  • GET /system-config - 获取所有配置
  • GET /system-config/public - 获取公开配置
  • GET /system-config/type/{type} - 根据类型获取配置
  • GET /system-config/key/{key} - 根据Key获取配置
  • GET /system-config/homepage - 获取首页配置
  • GET /system-config/homepage/entries - 获取首页快捷入口
  • PUT /system-config/batch - 批量更新配置

安全监控

  • GET /security-monitor/login-stats - 获取登录统计
  • GET /security-monitor/login-history - 获取登录历史
  • GET /security-monitor/pending-anomalies - 获取待处理异常
  • GET /security-monitor/high-severity-anomalies - 获取高危异常
  • POST /security-monitor/anomalies/{id}/resolve - 解决异常

知识库管理

  • GET /knowledge - 获取所有知识
  • GET /knowledge/search?keyword=xxx - 搜索知识
  • GET /knowledge/popular - 热门知识
  • POST /knowledge/{id}/use - 使用知识
  • POST /knowledge/{id}/helpful - 标记有帮助

客户管理

  • GET /customers/{id} - 根据ID获取客户
  • GET /customers/no/{customerNo} - 根据客户编号获取客户
  • GET /customers/phone/{phone} - 根据手机号获取客户
  • GET /customers/high-risk - 获取高风险客户
  • GET /customers/top-value - 获取高价值客户
  • GET /customers/vip - 获取VIP客户
  • POST /customers - 创建客户
  • PUT /customers/{id} - 更新客户信息
  • POST /customers/{id}/risk-assessment - 更新风险评估

反馈管理

  • POST /feedback - 提交反馈
  • GET /feedback/my - 获取我的反馈
  • GET /feedback/customer/{customerId} - 获取客户反馈历史
  • GET /feedback/my-average - 获取我的平均满意度
  • GET /feedback/overall-average - 获取整体平均满意度
  • GET /feedback/require-followup - 获取需要跟进的反馈
  • GET /feedback/statistics - 反馈统计

高频问题分析

  • GET /frequent-questions/top - 获取热门问题Top20
  • GET /frequent-questions/recent - 获取最近高频问题
  • GET /frequent-questions/analysis-report - 获取分析报告
  • POST /frequent-questions/record - 记录问题
  • GET /frequent-questions/without-answer - 获取未关联答案的高频问题
  • POST /frequent-questions/analyze-messages - 从历史消息中分析常见问题
  • GET /frequent-questions/{id}/recommend-scripts - 根据高频问题推荐话术

质量监控

  • GET /quality-monitor/my-score - 获取我的质量评分
  • GET /quality-monitor/real-time-metrics - 获取实时质量指标
  • POST /quality-monitor/check-session/{id} - 会话质检
  • GET /quality-monitor/alerts - 获取质量告警
  • GET /quality-monitor/report - 生成质量报告

第三方API配置说明

🚀 快速配置 API Key

系统已在 application.yml 中预置了第三方API配置模板,无需修改代码,只需填写你的 API Key:

步骤1:打开配置文件

编辑 src/main/resources/application.yml,找到 third-party: 配置段

步骤2:填写你的API信息

third-party:
  # 智能对话API (OpenAI / 通义千问 / 文心一言)
  ai:
    provider: openai  # 选择服务商
    api-url: https://api.openai.com/v1/chat/completions
    api-key: sk-proj-xxxxxxxxxx  # ⬅️ 填写你的API Key
    model: gpt-3.5-turbo

  # 短信服务API (阿里云 / 腾讯云)
  sms:
    provider: aliyun
    access-key-id: LTAI5xxxxxxxxxx     # ⬅️ 填写你的Key
    access-key-secret: xxxxxxxxxx      # ⬅️ 填写你的Secret

  # 邮件服务API
  email:
    api-url: smtp.qq.com
    api-key: xxxxxxxxxxxxxxxx  # ⬅️ QQ邮箱授权码
    from: your-email@qq.com

步骤3:保存并重启应用

配置完成后重启应用即可使用!

📚 详细文档

  • 🔑 API配置快速指南: 查看下方API配置详细说明
  • 📖 API对接详细说明: 查看下方API对接指南
  • 💡 API使用示例: 查看下方API使用示例

支持的第三方服务

1. AI智能对话

  • OpenAI GPT (gpt-3.5-turbo, gpt-4)
  • 阿里云通义千问 (qwen-turbo, qwen-max)
  • 百度文心一言 (ERNIE-Bot)

2. 短信服务

  • 阿里云短信服务
  • 腾讯云短信服务

3. 邮件服务

  • SMTP (支持QQ邮箱、163邮箱等)
  • SendGrid
  • Mailgun

4. 语音识别

  • 科大讯飞
  • 百度语音识别
  • 腾讯云语音识别

🔒 安全提示

生产环境建议使用环境变量,而不是直接在配置文件中写API Key:

third-party:
  ai:
    api-key: ${OPENAI_API_KEY:}  # 从环境变量读取

设置环境变量:

# Windows
set OPENAI_API_KEY=sk-proj-xxxxxxxxxx

# Linux/Mac
export OPENAI_API_KEY="sk-proj-xxxxxxxxxx"

数据库表结构

主要数据表:

  • sys_user - 用户表
  • request_type - 诉求类型表
  • service_flow - 服务流程表
  • flow_step - 流程步骤表
  • script - 话术表
  • script_favorite - 话术收藏表
  • session - 会话表
  • message - 消息表
  • session_step - 会话步骤记录表
  • work_order - 工单表
  • service_record - 服务记录表
  • system_config - 系统配置表
  • login_log - 登录日志表
  • anomaly_log - 异常日志表
  • knowledge - 知识库表
  • customer - 客户表
  • feedback - 反馈表
  • frequent_question - 高频问题表

默认账号

系统启动后可使用以下默认账号登录(需先执行初始化脚本):

  • 管理员: admin / admin123
  • 坐席: agent / agent123

开发建议

  1. 使用开发环境配置: --spring.profiles.active=dev
  2. API测试推荐使用Postman或通过Swagger UI
  3. WebSocket测试可使用在线工具或编写前端测试页面
  4. 建议使用Redis Desktop Manager查看缓存数据

部署说明

Docker部署(推荐)

# 构建镜像
docker build -t agent-system:1.0 .

# 运行容器
docker run -d -p 8080:8080 \
  -e DB_USERNAME=root \
  -e DB_PASSWORD=password \
  -e REDIS_HOST=redis \
  agent-system:1.0

传统部署

# 打包
mvn clean package -DskipTests

# 运行
java -jar target/agent-1.0-SNAPSHOT.jar --spring.profiles.active=prod

新增功能详细说明

系统配置管理

实体: SystemConfig 功能:

  • 首页配置管理(标题、Logo、入口配置)
  • 登录页配置管理(背景、标题、样式)
  • 系统参数配置
  • 支持按类型分组管理

登录监控与异常检测

实体: LoginLog, AnomalyLog 功能:

  • 登录日志记录(成功/失败、IP、设备类型)
  • 登录次数统计
  • 异常登录检测(多次失败、异地登录)
  • 安全告警机制

异常检测规则:

  • 1小时内失败登录超过5次 → HIGH级别告警
  • 同一IP 1小时内失败超过10次 → HIGH级别告警

知识库管理

实体: Knowledge 功能:

  • 知识文档管理(增删改查)
  • 知识分类和标签
  • 智能搜索(标题、内容、关键词)
  • 浏览次数、使用次数统计
  • 有帮助/无帮助反馈

客户管理(画像与风险评估)

实体: Customer 功能:

  • 客户基本信息管理
  • 客户画像(VIP等级、消费金额、服务次数)
  • 风险评估(基于投诉、满意度等)
  • 客户分级管理

风险评估规则:

  • 投诉次数 > 5次:+30分
  • 平均满意度 < 3分:+20分
  • 风险分数 >= 50:HIGH风险

满意度评价闭环

实体: Feedback 功能:

  • 多维度满意度评价(服务态度、问题解决、响应速度等)
  • 评价统计分析
  • 需要跟进的反馈管理
  • 自动更新客户满意度

高频问题分析

实体: FrequentQuestion 功能:

  • 自动记录高频问题
  • 问题去重(基于MD5哈希)
  • 问题热度统计
  • 关联标准答案、话术、知识库

服务质量监控

服务: QualityMonitorService 功能:

  • 坐席质量评分(满意度、响应速度、服务量)
  • 实时质量指标监控
  • 会话质量检查
  • 质量报告生成

评分体系:

  • 满意度评分:基于用户评价
  • 速度评分:5分钟内100分,超过10分钟0分
  • 服务量评分:每天20单满分

API配置详细说明

快速开始:配置第三方API

系统已在 src/main/resources/application.yml 中预置了第三方API配置模板。

步骤1️⃣:打开配置文件

找到 application.yml 文件底部的 third-party 配置段。

步骤2️⃣:填写你的API信息

根据需要,修改对应服务的配置:

third-party:
  # 智能对话API配置
  ai:
    provider: openai  # 你使用的服务商
    api-url: https://api.openai.com/v1/chat/completions  # API地址
    api-key: sk-xxxxxxxxxxxxxxxx  # 替换为你的真实API Key
    model: gpt-3.5-turbo
    timeout: 30000
    max-tokens: 2000
    temperature: 0.7

  # 短信服务API配置
  sms:
    provider: aliyun
    api-url: https://dysmsapi.aliyuncs.com
    access-key-id: LTAI5xxxxxxxxxx  # 替换为你的AccessKeyId
    access-key-secret: xxxxxxxxxxxxx  # 替换为你的AccessKeySecret
    sign-name: 您的签名名称
    template-code: SMS_123456789

  # 邮件服务API配置
  email:
    provider: smtp
    api-url: smtp.qq.com
    api-key: xxxxxxxxxxxxxxxx  # QQ邮箱授权码或其他邮箱密码
    from: your-email@qq.com  # 发件人邮箱
    port: 587

步骤3️⃣:保存并重启应用

修改完成后,保存文件并重启Spring Boot应用,配置即生效。

不同服务商的配置示例

OpenAI GPT

third-party:
  ai:
    provider: openai
    api-url: https://api.openai.com/v1/chat/completions
    api-key: sk-proj-xxxxxxxxxxxxxxxxxxxxxxxx
    model: gpt-3.5-turbo  # 或 gpt-4

获取API Key: https://platform.openai.com/api-keys

阿里云通义千问

third-party:
  ai:
    provider: tongyi
    api-url: https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation
    api-key: sk-xxxxxxxxxxxxxxxxxxxxxxxx
    model: qwen-turbo

获取API Key: https://dashscope.console.aliyun.com/apiKey

百度文心一言

third-party:
  ai:
    provider: wenxin
    api-url: https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions
    api-key: your-api-key
    model: ERNIE-Bot-turbo

获取API Key: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application

API对接指南

智能话术推荐

方案A: OpenAI GPT API

public List<String> suggestScripts(String context, String inputText) {
    // 添加依赖:com.theokanning.openai-gpt3-java
    OpenAiService service = new OpenAiService("YOUR_API_KEY");

    ChatCompletionRequest request = ChatCompletionRequest.builder()
        .model("gpt-3.5-turbo")
        .messages(Arrays.asList(
            new ChatMessage("system", "你是一个客服助手,根据上下文推荐合适的话术。上下文:" + context),
            new ChatMessage("user", inputText)
        ))
        .maxTokens(200)
        .build();

    ChatCompletionResult result = service.createChatCompletion(request);
    return result.getChoices().stream()
        .map(choice -> choice.getMessage().getContent())
        .collect(Collectors.toList());
}

方案B: 阿里云通义千问

public List<String> suggestScripts(String context, String inputText) {
    // 添加依赖:com.aliyun:dashscope-sdk-java
    Generation gen = new Generation();

    Message systemMsg = Message.builder()
        .role("system")
        .content("你是客服助手,根据上下文推荐话术:" + context)
        .build();

    Message userMsg = Message.builder()
        .role("user")
        .content(inputText)
        .build();

    GenerationParam param = GenerationParam.builder()
        .apiKey("YOUR_API_KEY")
        .model("qwen-turbo")
        .messages(Arrays.asList(systemMsg, userMsg))
        .build();

    GenerationResult result = gen.call(param);
    return Arrays.asList(result.getOutput().getText());
}

方案C: 百度文心一言

public List<String> suggestScripts(String context, String inputText) {
    // 使用百度千帆SDK
    String url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions";

    Map<String, Object> params = new HashMap<>();
    params.put("messages", Arrays.asList(
        Map.of("role", "user", "content", context + "\n" + inputText)
    ));

    // 发送HTTP请求
    // ... 返回结果
}

语音识别(Speech-to-Text)

阿里云语音识别

public String speechToText(String audioUrl) {
    // 添加依赖:com.aliyun:aliyun-java-sdk-core
    IAcsClient client = new DefaultAcsClient(profile);

    SpeechRecognitionRequest request = new SpeechRecognitionRequest();
    request.setFileLink(audioUrl);
    request.setFormat("wav");
    request.setSampleRate(16000);

    SpeechRecognitionResponse response = client.getAcsResponse(request);
    return response.getResult();
}

意图识别

使用NLP服务

public Long analyzeIntent(List<String> messages) {
    // 使用阿里云NLP
    String url = "https://nlp.cn-shanghai.aliyuncs.com/";

    Map<String, Object> params = new HashMap<>();
    params.put("text", String.join("\n", messages));
    params.put("service", "intent_classification");

    // 发送请求并解析结果
    // 根据识别出的意图返回对应的诉求类型ID

    return requestTypeId;
}

情感分析

百度情感分析API

public Integer analyzeSentiment(String text) {
    String url = "https://aip.baidubce.com/rpc/2.0/nlp/v1/sentiment_classify";

    Map<String, String> params = new HashMap<>();
    params.put("text", text);

    // 发送请求
    JSONObject response = sendRequest(url, params);

    // 解析情感得分(0-4分别对应:非常负面、负面、中性、正面、非常正面)
    int sentiment = response.getJSONObject("items").getInt("sentiment");
    return sentiment + 1; // 转换为1-5分
}

数字人交互

商汤数字人API示例

public Map<String, String> digitalAvatarInteract(String message, String digitalAvatarId) {
    String apiUrl = "https://api.sensetime.com/digital-avatar/interact";

    Map<String, Object> params = new HashMap<>();
    params.put("avatar_id", digitalAvatarId);
    params.put("text", message);
    params.put("emotion", "neutral");

    JSONObject response = sendRequest(apiUrl, params);

    return Map.of(
        "text", response.getString("response_text"),
        "videoUrl", response.getString("video_url")
    );
}

API使用示例

1. 用户认证

登录

curl -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "admin",
    "password": "admin123"
  }'

获取当前用户信息

curl -X GET http://localhost:8080/api/auth/current \
  -H "Authorization: Bearer YOUR_TOKEN"

2. 诉求类型管理

获取所有启用的诉求类型

curl -X GET http://localhost:8080/api/request-types/active \
  -H "Authorization: Bearer YOUR_TOKEN"

创建诉求类型

curl -X POST http://localhost:8080/api/request-types \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "话费咨询",
    "code": "BILL_CONSULT",
    "description": "话费相关咨询",
    "icon": "bill",
    "color": "#409EFF",
    "sortOrder": 1,
    "status": true
  }'

3. 话术管理

搜索话术

curl -X GET "http://localhost:8080/api/scripts/search?keyword=您好" \
  -H "Authorization: Bearer YOUR_TOKEN"

添加到收藏

curl -X POST http://localhost:8080/api/scripts/favorites \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "scriptId": 1,
    "customTitle": "我的常用问候语",
    "customTags": "常用,问候"
  }'

4. 会话管理

创建会话

curl -X POST http://localhost:8080/api/sessions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "13800138000",
    "customerName": "张三",
    "customerPhone": "13800138000",
    "requestTypeId": 1
  }'

发送消息

curl -X POST http://localhost:8080/api/sessions/1/messages \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "您好,请问有什么可以帮助您?",
    "type": "TEXT",
    "senderName": "客服小张"
  }'

5. 工单管理

创建工单

curl -X POST http://localhost:8080/api/work-orders \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "网络故障",
    "description": "客户反馈网络无法连接",
    "sessionId": 1,
    "requestTypeId": 3,
    "priority": 3,
    "customerId": "13800138000",
    "customerName": "张三",
    "customerPhone": "13800138000"
  }'

6. AI智能服务

智能话术建议

curl -X POST http://localhost:8080/api/ai/suggest-scripts \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "context": "客户咨询话费",
    "inputText": "我想查一下"
  }'

7. 数据分析

获取个人统计数据

curl -X GET "http://localhost:8080/api/analytics/my-statistics?startTime=2024-01-01T00:00:00&endTime=2024-01-31T23:59:59" \
  -H "Authorization: Bearer YOUR_TOKEN"

8. 系统配置管理

配置首页

curl -X PUT http://localhost:8080/api/system-config/batch \
  -H "Authorization: Bearer TOKEN" \
  -d '{
    "homepage.title": "我的客服系统",
    "homepage.logo": "/assets/my-logo.png"
  }'

9. 安全监控

查看登录历史

curl -X GET "http://localhost:8080/api/security-monitor/login-history?startTime=2024-01-01T00:00:00&endTime=2024-12-31T23:59:59" \
  -H "Authorization: Bearer TOKEN"

10. 知识库管理

搜索知识库

curl -X GET "http://localhost:8080/api/knowledge/search?keyword=话费" \
  -H "Authorization: Bearer TOKEN"

11. 高频问题分析

获取高频问题

curl -X GET "http://localhost:8080/api/frequent-questions/top?limit=20" \
  -H "Authorization: Bearer TOKEN"

12. 质量监控

查看质量评分

curl -X GET "http://localhost:8080/api/quality-monitor/my-score?startTime=2024-01-01T00:00:00" \
  -H "Authorization: Bearer TOKEN"

注意事项

  1. 安全性:

    • 修改默认的JWT密钥
    • 在生产环境使用强密码
    • 启用HTTPS
  2. 性能优化:

    • 合理使用Redis缓存
    • 数据库索引优化
    • 启用数据库连接池
  3. 第三方API:

    • 需要自行申请API密钥
    • 注意API调用频率限制
    • 处理好异常情况
  4. 数据库迁移:

    • 如果您已经运行了旧版本,新表会通过JPA的ddl-auto: update自动创建
    • 或者可以重新执行init.sql初始化脚本

许可证

MIT License

联系方式

如有问题,请联系项目维护者。

About

Seat AI Agent is an AI-powered system that automates customer interactions specifically for seating services—handling reservations, seat assignments, upgrades, and issue resolution in real-time, commonly used in airline, theater, and event management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages