feat: sxbh.ltd AI自动获客组件+lead API
This commit is contained in:
@@ -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分钟内联系您"}
|
||||||
+2
-1
@@ -5,7 +5,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from app.database import init_db
|
from app.database import init_db
|
||||||
from app.api import auth, kpis, templates, maps, dashboard, data, alerts, ai_analysis, alert_rules, users, thresholds, notifications, permissions, action_plans, alignment, org, objectives, versions, budget, cost, predict, reports, security, knowledge, bot_bridge, bot_bridge_v2, customer_dashboard, deviation_push, budget_generate, knowledge_articles, kpi_causality, data_quality, bi_reports, entities, bsc_layers, okr, okr_templates, subjects, driver_budget
|
from app.api import auth, kpis, templates, maps, dashboard, data, alerts, ai_analysis, alert_rules, users, thresholds, notifications, permissions, action_plans, alignment, org, objectives, versions, budget, cost, predict, reports, security, knowledge, bot_bridge, bot_bridge_v2, lead, customer_dashboard, deviation_push, budget_generate, knowledge_articles, kpi_causality, data_quality, bi_reports, entities, bsc_layers, okr, okr_templates, subjects, driver_budget
|
||||||
from app.utils.cache import clear_all as clear_cache, delete as delete_cache
|
from app.utils.cache import clear_all as clear_cache, delete as delete_cache
|
||||||
from scripts.erp_sync import run_sync as run_erp_sync
|
from scripts.erp_sync import run_sync as run_erp_sync
|
||||||
from app.auth_middleware import require_auth
|
from app.auth_middleware import require_auth
|
||||||
@@ -56,6 +56,7 @@ app.include_router(security.router)
|
|||||||
app.include_router(knowledge.router)
|
app.include_router(knowledge.router)
|
||||||
app.include_router(bot_bridge.router)
|
app.include_router(bot_bridge.router)
|
||||||
app.include_router(bot_bridge_v2.router)
|
app.include_router(bot_bridge_v2.router)
|
||||||
|
app.include_router(lead.router)
|
||||||
app.include_router(customer_dashboard.router)
|
app.include_router(customer_dashboard.router)
|
||||||
app.include_router(deviation_push.router)
|
app.include_router(deviation_push.router)
|
||||||
app.include_router(budget_generate.router)
|
app.include_router(budget_generate.router)
|
||||||
|
|||||||
Reference in New Issue
Block a user