每个客户拥有唯一的沟通时间轴,聚合所有渠道沟通记录:
客户:宁波奥克斯空调有限公司
├─ 沟通时间轴 (Timeline)
│ ├─ [2024-06-15 09:30] 📞 400电话 - 张经理询价PCR-ABS
│ ├─ [2024-06-15 10:15] 💬 企业微信 - 发送产品报价单
│ ├─ [2024-06-15 14:00] 📧 Email - 确认技术参数
│ ├─ [2024-06-16 09:00] 🤝 商务拜访 - 工厂考察
│ ├─ [2024-06-16 16:30] 📞 移动电话 - 讨论账期
│ ├─ [2024-06-17 11:00] 💬 企业微信 - 确认订单意向
│ └─ [2024-06-17 15:00] 📧 Email - 发送合同草案
┌─────────────────────────────────────────────────────────────┐
│ 全渠道沟通接入层 │
├─────────────────────────────────────────────────────────────┤
│ 📞 400电话 │ 💬 企业微信 │ 📧 Email │ 🤝 拜访/出差 │
│ 📱 移动电话 │ 🎥 视频会议 │ 📝 表单 │ 🌐 官网咨询 │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 沟通聚合引擎 (Aggregation Engine) │
├─────────────────────────────────────────────────────────────┤
│ • 数据标准化 │ • 去重合并 │ • 时间排序 │ • 关联分析 │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 统一沟通数据库 │
├─────────────────────────────────────────────────────────────┤
│ customer_communications (主表) │
│ communication_attachments (附件) │
│ communication_insights (AI洞察) │
│ communication_tasks (跟进任务) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ AI Agent 分析层 │
├─────────────────────────────────────────────────────────────┤
│ 🤖 沟通分析Agent │ 🎯 营销建议Agent │ ⚠️ 风险预警Agent │
│ 📊 客户洞察Agent │ 💡 商机挖掘Agent │ 📝 报告生成Agent │
└─────────────────────────────────────────────────────────────┘
---
-- 全渠道沟通记录主表
CREATE TABLE IF NOT EXISTS customer_communications (
id SERIAL PRIMARY KEY,
record_id VARCHAR(64) NOT NULL UNIQUE,
tenant_id VARCHAR(64) DEFAULT 'T001',
-- 关联信息
customer_id VARCHAR(64) NOT NULL,
contact_id INTEGER,
project_id VARCHAR(64),
opportunity_id VARCHAR(64),
-- 沟通类型与渠道
communication_type VARCHAR(32) NOT NULL,
-- phone: 电话
-- mobile: 移动电话
-- wechat: 企业微信
-- email: 邮件
-- meeting: 会议
-- visit: 拜访/出差
-- video: 视频会议
-- form: 表单提交
-- webchat: 官网咨询
direction VARCHAR(16), -- inbound/outbound
channel VARCHAR(32), -- 具体渠道
-- 时间信息
communication_time TIMESTAMP NOT NULL,
duration INTEGER, -- 时长(秒)
timezone VARCHAR(32) DEFAULT 'Asia/Shanghai',
-- 参与人员
initiated_by VARCHAR(64), -- 发起人
handled_by VARCHAR(64), -- 处理人
assigned_to VARCHAR(64), -- 分配人
participants JSONB, -- 参与人员列表
-- 内容信息
subject VARCHAR(256), -- 主题/标题
summary TEXT, -- AI摘要
content TEXT, -- 完整内容/文字记录
content_original TEXT, -- 原始内容(未处理)
recording_url VARCHAR(256), -- 录音/录像链接
-- 附件
attachment_count INTEGER DEFAULT 0,
attachment_urls JSONB, -- 附件列表
-- 意图分析(AI)
intent_category VARCHAR(32),
-- inquiry: 询价
-- complaint: 投诉
-- technical: 技术支持
-- cooperation: 合作洽谈
-- order: 订单确认
-- payment: 付款/账期
-- delivery: 交货
-- after_sales: 售后
-- other: 其他
intent_detail VARCHAR(128),
intent_confidence DECIMAL(3,2), -- 置信度
-- 关键信息提取(AI)
products_mentioned JSONB, -- 提到的产品
price_discussed DECIMAL(12,2), -- 讨论的价格
quantity_discussed INTEGER, -- 讨论的数量
timeline_mentioned JSONB, -- 提到的时间节点
competitors_mentioned JSONB, -- 提到的竞争对手
-- 情绪分析(AI)
sentiment VARCHAR(16), -- positive/neutral/negative
sentiment_score DECIMAL(3,2), -- 情绪分数
customer_mood VARCHAR(32), -- 客户心情描述
-- 紧急程度
urgency_level VARCHAR(16), -- high/medium/low
urgency_reason VARCHAR(128),
-- 跟进信息
follow_up_required BOOLEAN DEFAULT FALSE,
follow_up_items JSONB, -- 跟进事项列表
follow_up_deadline TIMESTAMP,
follow_up_status VARCHAR(32) DEFAULT 'pending',
-- 关联沟通(上下文)
parent_record_id VARCHAR(64), -- 父记录(回复/跟进)
thread_id VARCHAR(64), -- 会话线程ID
related_records JSONB, -- 关联记录列表
-- AI洞察
ai_insights JSONB, -- AI分析洞察
ai_suggestions JSONB, -- AI建议
ai_tags JSONB, -- AI标签
-- 系统字段
source_system VARCHAR(32), -- 来源系统
source_record_id VARCHAR(64), -- 源系统记录ID
sync_status VARCHAR(32) DEFAULT 'synced', -- synced/pending/failed
sync_error TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
created_by VARCHAR(64),
updated_by VARCHAR(64)
);
-- 索引
CREATE INDEX idx_comm_customer ON customer_communications(customer_id);
CREATE INDEX idx_comm_time ON customer_communications(communication_time);
CREATE INDEX idx_comm_type ON customer_communications(communication_type);
CREATE INDEX idx_comm_intent ON customer_communications(intent_category);
CREATE INDEX idx_comm_sentiment ON customer_communications(sentiment);
CREATE INDEX idx_comm_urgency ON customer_communications(urgency_level);
CREATE INDEX idx_comm_follow_up ON customer_communications(follow_up_required);
CREATE INDEX idx_comm_thread ON customer_communications(thread_id);
CREATE INDEX idx_comm_source ON customer_communications(source_system);
-- 复合索引:客户+时间(用于时间轴查询)
CREATE INDEX idx_comm_customer_time ON customer_communications(customer_id, communication_time DESC);
-- 沟通附件表
CREATE TABLE IF NOT EXISTS communication_attachments (
id SERIAL PRIMARY KEY,
attachment_id VARCHAR(64) NOT NULL UNIQUE,
record_id VARCHAR(64) REFERENCES customer_communications(record_id),
-- 附件信息
file_name VARCHAR(256),
file_type VARCHAR(64), -- pdf/doc/xls/jpg/mp3/mp4
file_size INTEGER, -- 字节
file_url VARCHAR(256),
file_hash VARCHAR(64), -- 文件哈希(去重)
-- 附件内容(AI提取)
ocr_text TEXT, -- OCR文字(图片/PDF)
ai_summary TEXT, -- AI摘要
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- AI沟通洞察表
CREATE TABLE IF NOT EXISTS communication_insights (
id SERIAL PRIMARY KEY,
insight_id VARCHAR(64) NOT NULL UNIQUE,
customer_id VARCHAR(64) NOT NULL,
-- 洞察类型
insight_type VARCHAR(32),
-- relationship: 关系分析
-- opportunity: 商机分析
-- risk: 风险预警
-- suggestion: 营销建议
-- trend: 趋势分析
-- summary: 沟通总结
-- 洞察内容
insight_title VARCHAR(256),
insight_content TEXT,
insight_data JSONB, -- 结构化数据
-- 关联记录
related_records JSONB, -- 关联的沟通记录ID
record_count INTEGER, -- 分析的记录数量
time_range JSONB, -- 分析时间范围
-- 置信度与评分
confidence DECIMAL(3,2),
importance_score INTEGER, -- 重要程度 1-10
-- 处理状态
status VARCHAR(32) DEFAULT 'new', -- new/read/acted/dismissed
handled_by VARCHAR(64),
handled_at TIMESTAMP,
handle_result TEXT,
-- 通知状态
notification_sent BOOLEAN DEFAULT FALSE,
notification_time TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
generated_by VARCHAR(64) -- AI Agent ID
);
---
# 企业微信消息同步配置
WECHAT_WORK_SYNC_CONFIG = {
"corp_id": "YOUR_CORP_ID",
"corp_secret": "YOUR_CORP_SECRET",
"agent_id": "YOUR_AGENT_ID",
"sync_settings": {
"message_types": [
"text", # 文本消息
"image", # 图片
"voice", # 语音
"video", # 视频
"file", # 文件
"link", # 链接
"location", # 位置
"news" # 图文
],
"sync_direction": "both", # inbound/outbound/both
"sync_history": True, # 同步历史记录
"history_days": 365, # 同步最近365天
"real_time": True # 实时同步
},
"message_handler": {
"text": {
"extract_content": True,
"sentiment_analysis": True,
"intent_recognition": True
},
"image": {
"ocr": True, # OCR识别文字
"object_detection": True # 物体识别
},
"voice": {
"transcription": True, # 语音转文字
"speaker_recognition": True # 说话人识别
},
"file": {
"parse_content": True, # 解析文件内容
"extract_metadata": True # 提取元数据
}
}
}
# 企业微信消息处理
async def handle_wechat_message(message: dict):
"""
处理企业微信消息
"""
# 1. 解析消息
msg_type = message["msg_type"]
from_user = message["from_user"]
to_user = message["to_user"]
content = message["content"]
create_time = message["create_time"]
# 2. 识别客户
customer = await identify_customer_by_wechat(from_user)
# 3. 构建沟通记录
record = {
"record_id": f"WX-{create_time}-{uuid.uuid4().hex[:8]}",
"customer_id": customer["id"],
"communication_type": "wechat",
"direction": "inbound" if customer else "outbound",
"channel": "企业微信",
"communication_time": datetime.fromtimestamp(create_time),
"initiated_by": from_user,
"handled_by": to_user,
"participants": [from_user, to_user],
"subject": content[:50] if msg_type == "text" else f"[{msg_type}]",
"content": content,
"content_original": json.dumps(message),
"source_system": "wechat_work",
"source_record_id": message["msg_id"]
}
# 4. 特殊处理
if msg_type == "image":
# OCR识别
ocr_result = await ocr_image(message["image_url"])
record["content"] = f"[图片] {ocr_result['text']}"
record["attachment_urls"] = [message["image_url"]]
elif msg_type == "voice":
# 语音转文字
transcription = await transcribe_voice(message["voice_url"])
record["content"] = f"[语音] {transcription['text']}"
record["recording_url"] = message["voice_url"]
record["duration"] = transcription["duration"]
elif msg_type == "file":
# 解析文件
file_info = await parse_file(message["file_url"])
record["content"] = f"[文件] {file_info['name']}"
record["attachment_urls"] = [message["file_url"]]
# 5. AI分析
ai_result = await analyze_communication(record)
record.update(ai_result)
# 6. 保存
await save_communication_record(record)
# 7. 触发AI Agent分析
await trigger_ai_agents(record)
return record
# Email同步配置
EMAIL_SYNC_CONFIG = {
"imap_servers": [
{"host": "imap.exmail.qq.com", "port": 993, "ssl": True}, # 企业邮箱
],
"smtp_servers": [
{"host": "smtp.exmail.qq.com", "port": 465, "ssl": True},
],
"sync_settings": {
"check_interval": 300, # 每5分钟检查一次
"sync_folders": ["INBOX", "Sent", "Drafts"],
"max_email_size": 50 * 1024 * 1024, # 50MB
"attachment_save": True,
"attachment_path": "/var/attachments/email/"
},
"email_parsing": {
"extract_body": True,
"extract_attachments": True,
"extract_headers": True,
"parse_html": True,
"thread_detection": True # 检测邮件线程
}
}
# 邮件处理
async def handle_email(email_data: dict):
"""
处理邮件
"""
# 1. 解析邮件
msg_id = email_data["message_id"]
from_addr = email_data["from"]
to_addrs = email_data["to"]
subject = email_data["subject"]
body = email_data["body"]
sent_time = email_data["date"]
attachments = email_data["attachments"]
# 2. 识别客户(通过邮箱域名或联系人)
customer = await identify_customer_by_email(from_addr)
# 3. 检测邮件线程
thread_id = await detect_email_thread(msg_id, subject)
# 4. 构建沟通记录
record = {
"record_id": f"EMAIL-{sent_time.strftime('%Y%m%d')}-{uuid.uuid4().hex[:8]}",
"customer_id": customer["id"] if customer else None,
"communication_type": "email",
"direction": "inbound" if customer else "outbound",
"channel": "Email",
"communication_time": sent_time,
"initiated_by": from_addr,
"handled_by": to_addrs[0] if to_addrs else None,
"participants": [from_addr] + to_addrs,
"subject": subject,
"content": body,
"content_original": json.dumps(email_data),
"attachment_count": len(attachments),
"attachment_urls": [att["url"] for att in attachments],
"thread_id": thread_id,
"source_system": "email",
"source_record_id": msg_id
}
# 5. 解析邮件内容(AI)
email_insights = await parse_email_content(body)
record["intent_category"] = email_insights["intent"]
record["products_mentioned"] = email_insights["products"]
record["price_discussed"] = email_insights["price"]
# 6. 保存
await save_communication_record(record)
# 7. 触发AI Agent
await trigger_ai_agents(record)
return record
# 视频会议同步配置
VIDEO_CONFERENCE_CONFIG = {
"supported_platforms": [
"tencent_meeting", # 腾讯会议
"dingtalk", # 钉钉
"zoom", # Zoom
"teams" # Microsoft Teams
],
"sync_settings": {
"record_meeting": True, # 录制会议
"transcription": True, # 实时转录
"speaker_identification": True, # 说话人识别
"action_item_extraction": True, # 提取行动项
}
}
# 会议处理
async def handle_video_conference(meeting_data: dict):
"""
处理视频会议
"""
meeting_id = meeting_data["meeting_id"]
platform = meeting_data["platform"]
start_time = meeting_data["start_time"]
end_time = meeting_data["end_time"]
participants = meeting_data["participants"]
recording_url = meeting_data["recording_url"]
# 1. 识别客户(通过参会人)
customer = await identify_customer_by_participants(participants)
# 2. 语音转文字(会议录音)
transcription = await transcribe_meeting_recording(recording_url)
# 3. 提取行动项
action_items = await extract_action_items(transcription["text"])
# 4. 构建沟通记录
record = {
"record_id": f"MEETING-{start_time.strftime('%Y%m%d')}-{uuid.uuid4().hex[:8]}",
"customer_id": customer["id"] if customer else None,
"communication_type": "video",
"direction": "inbound",
"channel": platform,
"communication_time": start_time,
"duration": (end_time - start_time).seconds,
"initiated_by": meeting_data["organizer"],
"participants": participants,
"subject": meeting_data["topic"],
"content": transcription["text"],
"summary": transcription["summary"],
"recording_url": recording_url,
"follow_up_required": len(action_items) > 0,
"follow_up_items": action_items,
"source_system": platform,
"source_record_id": meeting_id
}
# 5. 保存
await save_communication_record(record)
# 6. 触发AI Agent
await trigger_ai_agents(record)
return record
# 拜访/出差报告处理
async def handle_visit_report(report_data: dict):
"""
处理商务拜访或出差报告
"""
# 1. 解析报告
visit_id = report_data["visit_id"]
customer_id = report_data["customer_id"]
visit_date = report_data["visit_date"]
visit_location = report_data["location"]
sales_person = report_data["sales_person"]
report_content = report_data["content"]
# 2. 提取关键信息(AI)
visit_insights = await analyze_visit_report(report_content)
# 3. 构建沟通记录
record = {
"record_id": f"VISIT-{visit_date.strftime('%Y%m%d')}-{uuid.uuid4().hex[:8]}",
"customer_id": customer_id,
"communication_type": "visit",
"direction": "outbound",
"channel": "商务拜访",
"communication_time": visit_date,
"duration": report_data.get("duration_minutes", 0) * 60,
"initiated_by": sales_person,
"handled_by": sales_person,
"participants": report_data.get("customer_participants", []),
"subject": f"商务拜访 - {visit_location}",
"content": report_content,
"summary": visit_insights["summary"],
"location": visit_location,
"attachment_urls": report_data.get("photos", []),
"intent_category": visit_insights["intent"],
"products_mentioned": visit_insights["products"],
"follow_up_required": visit_insights["has_follow_up"],
"follow_up_items": visit_insights["follow_up_items"],
"source_system": "crm_visit",
"source_record_id": visit_id
}
# 4. 保存
await save_communication_record(record)
# 5. 触发AI Agent
await trigger_ai_agents(record)
return record
---
┌─────────────────────────────────────────────────────────────┐
│ 沟通智能分析中心 (Communication AI Center) │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ A10 沟通分析Agent │ │ A11 客户洞察Agent │ │
│ │ (Communication │ │ (Customer │ │
│ │ Analyst) │ │ Insight) │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ A12 商机挖掘Agent │ │ A13 营销建议Agent │ │
│ │ (Opportunity │ │ (Marketing │ │
│ │ Miner) │ │ Advisor) │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ A14 风险预警Agent │ │ A15 报告生成Agent │ │
│ │ (Risk Guard) │ │ (Report │ │
│ │ │ │ Generator) │ │
│ └─────────────────┘ └─────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ A16 沟通聚合分析Agent ││
│ │ (Unified Communication Aggregator) ││
│ │ 协调所有Agent,生成综合分析报告 ││
│ └─────────────────────────────────────────────────────────┘│
│ │
└─────────────────────────────────────────────────────────────┘
# A10 沟通分析Agent - 分析单条沟通记录
A10_PROMPT = """
你是TopcentralMall的沟通分析专家。请分析以下客户沟通记录,提取关键信息。
## 输入数据
沟通类型: {communication_type}
沟通渠道: {channel}
沟通时间: {communication_time}
客户: {customer_name}
内容: {content}
## 分析任务
1. 沟通意图识别(询价/投诉/技术支持/合作洽谈/订单确认/付款/交货/售后/其他)
2. 关键信息提取(产品型号、价格、数量、时间节点、竞争对手)
3. 客户情绪分析(正面/中性/负面,分数0-1)
4. 紧急程度评估(高/中/低)
5. 跟进事项识别
6. 沟通质量评分(1-10)
## 输出格式(JSON)
{
"intent": {
"category": "inquiry",
"detail": "询价PCR-ABS 1000系列",
"confidence": 0.95
},
"key_info": {
"products": ["PCR-ABS-1000"],
"price": null,
"quantity": "50吨/月",
"timeline": "希望7月试样",
"competitors": [" competitor_A"]
},
"sentiment": {
"overall": "positive",
"score": 0.75,
"mood": "客户态度积极,有明确采购意向"
},
"urgency": {
"level": "high",
"reason": "客户明确提到7月试样,时间紧迫"
},
"follow_up": [
"准备PCR-ABS-1000样品",
"提供技术参数表",
"安排7月试样时间"
],
"quality_score": 8,
"suggestions": [
"建议24小时内回复样品安排",
"邀请客户参观工厂增强信任"
]
}
"""
# A11 客户洞察Agent - 分析客户全量沟通数据
A11_PROMPT = """
你是TopcentralMall的客户洞察专家。请基于客户的全量沟通记录,生成深度客户洞察报告。
## 输入数据
客户名称: {customer_name}
分析时间范围: {start_date} 至 {end_date}
沟通记录数量: {record_count}
沟通记录摘要:
{communication_summaries}
## 分析任务
1. 客户关系健康度评分(0-100)
2. 客户沟通偏好分析(渠道/时间/频率)
3. 客户决策模式识别(理性/感性/价格敏感/质量优先)
4. 客户满意度趋势(上升/下降/稳定)
5. 客户忠诚度评估
6. 客户生命周期阶段(潜在客户/新客户/成长客户/成熟客户/流失风险)
7. 关键联系人影响力分析
8. 客户痛点与需求图谱
## 输出格式(JSON)
{
"relationship_health": {
"score": 85,
"trend": "upward",
"assessment": "关系良好,合作深度持续增加"
},
"communication_pattern": {
"preferred_channel": "企业微信",
"preferred_time": "工作日下午",
"frequency": "每周2-3次",
"response_speed": "平均2小时回复"
},
"decision_making": {
"style": "理性决策",
"key_factors": ["价格", "质量", "交期"],
"decision_maker": "采购部张经理(技术部李工有影响力)",
"decision_cycle": "2-3周"
},
"satisfaction": {
"current": 4.2,
"trend": "stable",
"strengths": ["产品质量", "响应速度"],
"pain_points": ["价格波动", "付款账期"]
},
"loyalty": {
"score": 78,
"risk_level": "low",
"retention_probability": 0.92
},
"lifecycle_stage": "成长客户",
"key_contacts": [
{"name": "张经理", "role": "采购决策", "influence": 0.9, "relationship": "良好"},
{"name": "李工", "role": "技术评估", "influence": 0.7, "relationship": "一般"}
],
"needs_map": {
"current": ["PCR-ABS稳定供应", "价格优化"],
"future": ["PCR-PC新材料", "技术支持"],
"latent": ["库存管理", "供应链金融"]
},
"risks": [
{"type": "价格敏感", "level": "medium", "mitigation": "提供长期价格锁定方案"}
],
"opportunities": [
{"type": "新品推广", "potential": "high", "action": "推荐PCR-PC系列"}
]
}
"""
# A12 商机挖掘Agent - 从沟通中挖掘商机
A12_PROMPT = """
你是TopcentralMall的商机挖掘专家。请从客户沟通记录中识别和评估商机。
## 输入数据
客户: {customer_name}
近期沟通记录: {recent_communications}
历史订单数据: {order_history}
## 分析任务
1. 显性商机识别(客户明确表达的需求)
2. 隐性商机挖掘(潜在需求信号)
3. 商机可行性评估
4. 竞争态势分析
5. 成交概率预测
6. 预计成交金额和时间
7. 推荐行动方案
## 输出格式(JSON)
{
"opportunities": [
{
"id": "OPP-202406-001",
"type": "explicit", # explicit/implicit
"description": "PCR-ABS月需求50吨,寻求替代供应商",
"product": "PCR-ABS-1000",
"quantity": "50吨/月",
"estimated_value": 750000,
"probability": 0.65,
"expected_close_date": "2024-08-15",
"stage": "需求确认",
"competitors": ["现有供应商A", "竞争对手B"],
"winning_factors": ["价格优势15%", "质量认证齐全"],
"risk_factors": ["客户对切换有顾虑", "账期要求60天"],
"recommended_actions": [
"提供3个月试样合作",
"邀请参观工厂",
"提供客户案例"
],
"urgency": "high"
}
],
"cross_sell_opportunities": [
{
"product": "PCR-PC-3000",
"reason": "客户在沟通中提到新产品开发需要工程塑料",
"potential_value": 500000,
"approach": "技术推荐"
}
],
"up_sell_opportunities": [
{
"current": "PCR-ABS-1000",
"upgrade": "PCR-ABS-2000(高性能)",
"reason": "客户提到产品性能要求提升",
"potential_value": 200000
}
]
}
"""
# A13 营销建议Agent - 生成个性化营销建议
A13_PROMPT = """
你是TopcentralMall的营销策略专家。请基于客户沟通分析,生成个性化营销建议。
## 输入数据
客户洞察: {customer_insights}
商机分析: {opportunity_analysis}
历史营销效果: {marketing_history}
## 分析任务
1. 客户细分与定位
2. 个性化营销内容建议
3. 最佳触达时机
4. 最佳沟通渠道
5. 营销活动设计
6. 客户关怀策略
7. 复购促进方案
8. 客户转介绍激励
## 输出格式(JSON)
{
"customer_segment": "VIP成长型客户",
"marketing_strategy": {
"approach": "价值深化",
"key_messages": ["稳定供应保障", "技术创新支持", "成本优化方案"],
"value_proposition": "不仅是供应商,更是您的材料技术合作伙伴"
},
"content_suggestions": [
{
"type": "技术白皮书",
"topic": "PCR-ABS在汽车部件中的应用案例",
"timing": "立即发送",
"channel": "企业微信+邮件"
},
{
"type": "工厂参观邀请",
"topic": "邀请参观新投产的PCR生产线",
"timing": "下周安排",
"channel": "电话+企业微信"
}
],
"timing_recommendations": {
"best_contact_days": ["周二", "周三", "周四"],
"best_contact_hours": ["10:00-11:30", "14:00-16:00"],
"avoid_times": ["周一上午", "周五下午"]
},
"channel_strategy": {
"primary": "企业微信",
"secondary": "电话",
"tertiary": "邮件",
"reason": "客户偏好即时沟通,企业微信响应最快"
},
"campaign_ideas": [
{
"name": "夏季稳定供应保障计划",
"target": "消除客户对旺季供应担忧",
"offer": "提前锁定Q3产能,价格不变",
"expected_response": 0.8
}
],
"care_strategy": {
"birthday_greeting": True,
"holiday_gifts": "端午节送样品礼盒",
"quarterly_business_review": True,
"industry_insights_sharing": "每月分享行业报告"
},
"retention_plan": {
"risk_signals": ["价格抱怨增加", "询价频率下降"],
"retention_actions": [
"高管拜访",
"定制化价格方案",
"联合技术开发"
]
}
}
"""
# A14 风险预警Agent - 识别客户流失风险
A14_PROMPT = """
你是TopcentralMall的风险预警专家。请监控客户沟通数据,识别潜在风险。
## 输入数据
客户沟通记录: {communication_records}
订单数据: {order_data}
客户行为数据: {behavior_data}
## 风险识别任务
1. 客户流失风险信号
2. 订单下滑预警
3. 投诉升级风险
4. 竞争对手渗透
5. 付款风险
6. 质量投诉风险
7. 关系恶化信号
## 输出格式(JSON)
{
"risk_alerts": [
{
"alert_id": "RISK-202406-001",
"customer_id": "C001",
"customer_name": "宁波奥克斯",
"risk_type": "churn_risk",
"risk_level": "high", # high/medium/low
"risk_score": 75,
"indicators": [
"近30天沟通频率下降50%",
"询价次数减少",
"提到竞争对手价格更低",
"付款延迟5天"
],
"triggered_at": "2024-06-15",
"expected_impact": "月订单损失50吨,约75万元",
"recommended_actions": [
"销售总监立即拜访",
"提供专项价格优惠",
"安排技术交流"
],
"escalation_required": True,
"escalation_to": "sales_director"
}
],
"early_warning_signals": {
"communication_decline": {
"detected": True,
"metric": "30天沟通次数",
"current": 2,
"baseline": 8,
"trend": "declining"
},
"price_sensitivity": {
"detected": True,
"evidence": "最近3次沟通均提到价格问题",
"severity": "medium"
}
}
}
"""
# A15 报告生成Agent - 生成各类分析报告
A15_PROMPT = """
你是TopcentralMall的报告生成专家。请基于沟通聚合数据,生成专业分析报告。
## 报告类型: {report_type}
## 分析对象: {target}
## 时间范围: {time_range}
## 数据输入
沟通记录: {communication_data}
洞察分析: {insight_data}
## 生成报告
### 日报 (Daily Report)
- 今日沟通统计
- 重要事项摘要
- 待办事项提醒
- 明日计划建议
### 周报 (Weekly Report)
- 本周沟通概览
- 客户活跃度分析
- 商机进展跟踪
- 风险预警汇总
- 下周行动计划
### 月报 (Monthly Report)
- 月度沟通分析
- 客户满意度趋势
- 商机转化分析
- 营销效果评估
- 客户流失分析
- 下月策略建议
### 客户专属报告
- 客户沟通全景图
- 关系健康度评估
- 合作价值分析
- 改进建议
## 输出格式: Markdown报告
"""
# A16 沟通聚合分析Agent - 协调所有Agent,生成综合分析
A16_PROMPT = """
你是TopcentralMall的沟通聚合分析总协调Agent。请协调各专业Agent,生成综合分析报告。
## 工作流程
1. 接收全渠道沟通数据
2. 调用A10分析单条记录
3. 调用A11生成客户洞察
4. 调用A12挖掘商机
5. 调用A13生成营销建议
6. 调用A14识别风险
7. 调用A15生成报告
8. 整合所有分析结果
## 输出格式
{
"analysis_summary": {
"total_records": 150,
"channels": {"wechat": 80, "phone": 40, "email": 20, "visit": 10},
"analysis_date": "2024-06-15"
},
"customer_insights": { /* A11输出 */ },
"opportunities": { /* A12输出 */ },
"marketing_suggestions": { /* A13输出 */ },
"risk_alerts": { /* A14输出 */ },
"reports": { /* A15输出 */ },
"action_plan": {
"immediate": [...],
"short_term": [...],
"long_term": [...]
}
}
"""
---
# 沟通聚合引擎
class CommunicationAggregationEngine:
"""
全渠道沟通聚合引擎
"""
def __init__(self):
self.channels = {
"phone": PhoneChannelHandler(),
"mobile": MobileChannelHandler(),
"wechat": WeChatChannelHandler(),
"email": EmailChannelHandler(),
"meeting": MeetingChannelHandler(),
"visit": VisitChannelHandler(),
"video": VideoChannelHandler()
}
self.ai_agents = {
"A10": CommunicationAnalysisAgent(),
"A11": CustomerInsightAgent(),
"A12": OpportunityMiningAgent(),
"A13": MarketingSuggestionAgent(),
"A14": RiskAlertAgent(),
"A15": ReportGenerationAgent(),
"A16": AggregationCoordinatorAgent()
}
async def process_incoming_communication(self, raw_data: dict, channel: str):
"""
处理 incoming 沟通数据
"""
# 1. 渠道特定处理
handler = self.channels.get(channel)
if not handler:
raise ValueError(f"Unknown channel: {channel}")
# 2. 标准化数据
standardized = await handler.standardize(raw_data)
# 3. 保存原始记录
record = await self.save_communication_record(standardized)
# 4. 触发AI分析
await self.trigger_ai_analysis(record)
return record
async def trigger_ai_analysis(self, record: dict):
"""
触发AI Agent分析
"""
# 1. A10 单条记录分析
a10_result = await self.ai_agents["A10"].analyze(record)
# 2. 更新记录
await self.update_record_with_ai_insights(record["id"], a10_result)
# 3. 检查是否需要深度分析
if a10_result.get("urgency", {}).get("level") == "high":
# 紧急:立即通知
await self.send_urgent_notification(record, a10_result)
# 4. 定期聚合分析(由定时任务触发)
# 这里只是触发,实际聚合分析由定时任务执行
async def run_periodic_analysis(self, customer_id: str, time_range: dict):
"""
运行定期聚合分析
"""
# 1. 获取客户全量沟通数据
records = await self.get_customer_communications(customer_id, time_range)
# 2. A16 协调分析
a16_result = await self.ai_agents["A16"].coordinate_analysis(
customer_id=customer_id,
records=records,
agents=self.ai_agents
)
# 3. 保存洞察
await self.save_insights(customer_id, a16_result)
# 4. 推送报告
await self.push_analysis_report(customer_id, a16_result)
return a16_result
# 定时任务配置
SCHEDULE_CONFIG = {
"daily_analysis": {
"schedule": "0 9 * * *", # 每天上午9点
"task": "generate_daily_report",
"target": "all_customers",
"agents": ["A10", "A15"]
},
"weekly_analysis": {
"schedule": "0 9 * * 1", # 每周一上午9点
"task": "generate_weekly_report",
"target": "all_customers",
"agents": ["A11", "A12", "A13", "A14", "A15"]
},
"monthly_analysis": {
"schedule": "0 9 1 * *", # 每月1日上午9点
"task": "generate_monthly_report",
"target": "all_customers",
"agents": ["A11", "A12", "A13", "A14", "A15", "A16"]
},
"real_time_alert": {
"schedule": "*/5 * * * *", # 每5分钟
"task": "check_risk_alerts",
"target": "high_priority_customers",
"agents": ["A14"]
}
}
---
┌─────────────────────────────────────────────────────────────┐
│ 客户沟通全景图 - 宁波奥克斯空调有限公司 │
├─────────────────────────────────────────────────────────────┤
│ 📊 关系健康度: 85/100 │ 📈 趋势: ↑ │ ⏰ 最后联系: 2小时前 │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 🔍 筛选: [全部 ▼] [时间 ▼] [渠道 ▼] [意图 ▼] │ │
│ │ 📅 时间轴视图 │ 📋 列表视图 │ 📊 分析视图 │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 今天 6月15日 │ │
│ │ ├─ 14:30 📞 400电话 (15分钟) │ │
│ │ │ 张经理询价PCR-ABS,月需求50吨 │ │
│ │ │ [意图: 询价] [情绪: 积极] [紧急: 高] │ │
│ │ │ [查看详情] [播放录音] [查看文字] │ │
│ │ │ │ │
│ │ ├─ 10:15 💬 企业微信 │ │
│ │ │ 发送产品报价单和技术参数 │ │
│ │ │ [意图: 报价] [情绪: 中性] [附件: 2个] │ │
│ │ │ │ │
│ │ ├─ 09:30 📧 Email │ │
│ │ 确认下周工厂参观安排 │ │
│ │ [意图: 会议确认] [情绪: 积极] │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 昨天 6月14日 │ │
│ │ ├─ 16:00 🤝 商务拜访 (2小时) │ │
│ │ │ 工厂考察,讨论长期合作 │ │
│ │ │ [意图: 合作洽谈] [拜访报告] [照片: 5张] │ │
│ │ │ │ │
│ │ ├─ 09:00 📞 移动电话 (8分钟) │ │
│ │ 讨论账期和付款方式 │ │
│ │ [意图: 付款] [情绪: 中性] │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 🤖 AI洞察 │ │
│ │ ├─ 💡 商机提醒: 客户有明确PCR-ABS采购意向,预计月订单50吨│ │
│ │ ├─ ⚠️ 风险预警: 客户提到竞争对手价格更低15% │ │
│ │ ├─ 🎯 营销建议: 建议提供3个月试样合作方案 │ │
│ │ └─ 📋 待办: 准备样品 + 安排工厂参观 + 提供客户案例 │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ 🤖 AI智能分析报告 - 宁波奥克斯 │
├─────────────────────────────────────────────────────────────┤
│ 生成时间: 2024-06-15 09:00 │ 分析范围: 近30天 │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 📊 一、客户洞察分析 │ │
│ │ │ │
│ │ 关系健康度: 85/100 (良好) │ │
│ │ ├─ 沟通频率: 每周3.2次 (高于平均) │ │
│ │ ├─ 响应速度: 平均1.5小时 (优秀) │ │
│ │ ├─ 满意度趋势: ↑ 上升 │ │
│ │ └─ 忠诚度: 78/100 (较高) │ │
│ │ │ │
│ │ 决策模式: 理性决策,重视技术验证和价格竞争力 │ │
│ │ 关键决策人: 张经理(采购) - 影响力90% │ │
│ │ 李工(技术) - 影响力70% │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 💰 二、商机分析 │ │
│ │ │ │
│ │ 显性商机: │ │
│ │ ├─ PCR-ABS月需求50吨,预计年订单600吨 │ │
│ │ ├─ 预计成交金额: 900万元/年 │ │
│ │ └─ 成交概率: 65% (需求确认阶段) │ │
│ │ │ │
│ │ 隐性商机: │ │
│ │ ├─ PCR-PC新材料需求 (客户提到新产品开发) │ │
│ │ └─ 供应链金融合作意向 │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 🎯 三、营销建议 │ │
│ │ │ │
│ │ 立即执行: │ │
│ │ 1. 提供3个月试样合作,锁定客户 │ │
│ │ 2. 邀请参观工厂,增强信任 │ │
│ │ 3. 提供同行业客户成功案例 │ │
│ │ │ │
│ │ 本周计划: │ │
│ │ 1. 发送PCR-ABS技术白皮书 │ │
│ │ 2. 安排技术交流会 (李工参与) │ │
│ │ 3. 提供专项价格优惠方案 │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ ⚠️ 四、风险预警 │ │
│ │ │ │
│ │ 高风险: │ │
│ │ ├─ 客户提到竞争对手价格更低15% │ │
│ │ ├─ 影响: 可能流失订单 │ │
│ │ └─ 应对: 立即提供价格匹配或价值证明 │ │
│ │ │ │
│ │ 中风险: │ │
│ │ └─ 付款账期要求60天 (目前30天) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 📋 五、行动清单 │ │
│ │ │ │
│ │ [紧急] 1. 销售总监拜访客户 (今天) │ │
│ │ [高] 2. 准备PCR-ABS样品 (明天) │ │
│ │ [高] 3. 制定价格优惠方案 (明天) │ │
│ │ [中] 4. 安排工厂参观 (本周) │ │
│ │ [中] 5. 准备技术交流会 (本周) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ [导出报告] [分享团队] [创建任务] [设置提醒] │
│ │
└─────────────────────────────────────────────────────────────┘
---
-- 执行数据库迁移脚本
-- 1. 创建新表
-- 2. 迁移历史数据
-- 3. 创建索引
-- 4. 验证数据完整性
| 阶段 | 时间 | 内容 | 优先级 |
|---|
| 第1阶段 | 第1周 | 400电话接入 | 高 |
| 第2阶段 | 第2周 | 企业微信接入 | 高 |
| 第3阶段 | 第3周 | Email接入 | 中 |
| 第4阶段 | 第4周 | 拜访/出差报告接入 | 中 |
| 第5阶段 | 第5周 | 视频会议接入 | 低 |
| Agent | 依赖 | 部署时间 | 状态 |
|---|
| A10 沟通分析 | 无 | 第1周 | 待部署 |
| A11 客户洞察 | A10 | 第2周 | 待部署 |
| A12 商机挖掘 | A10, A11 | 第2周 | 待部署 |
| A13 营销建议 | A11, A12 | 第3周 | 待部署 |
| A14 风险预警 | A10, A11 | 第3周 | 待部署 |
| A15 报告生成 | 全部 | 第4周 | 待部署 |
| A16 协调者 | 全部 | 第4周 | 待部署 |
---
**文档版本**: v1.0
**日期**: 2026-06-15
**状态**: 设计方案待审批
**审批人**: admin@topcentral.cn / 麻一明