feat: sxbh.ltd AI自动获客组件+lead API

This commit is contained in:
Hermes CI Fix
2026-07-22 18:16:12 +08:00
parent 2d0abe3411
commit c1384fd4ff
2 changed files with 28 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
"""AI获客 - 客户咨询接口"""
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
import json, os, datetime
router = APIRouter(prefix="/api/cma/lead", tags=["AI获客"])
class LeadRequest(BaseModel):
name: str
phone: str
requirement: str = ""
source: str = "sxbh.ltd"
@router.post("")
def create_lead(data: LeadRequest):
"""接收客户咨询并保存"""
record = data.model_dump()
record["timestamp"] = datetime.datetime.now().isoformat()
record["status"] = "new"
log_dir = "/root/leads"
os.makedirs(log_dir, exist_ok=True)
with open(f"{log_dir}/leads.json", "a") as f:
f.write(json.dumps(record, ensure_ascii=False) + "\n")
return {"success": True, "message": "咨询已提交,我们将在30分钟内联系您"}