import pyautogui import timefrom customer_tag_service import CustomerTagService from ai_agent_service import AIAgentService
def auto_accept_friend_request(): friend_request_windows = pyautogui.getWindowsWithTitle("微信-好友申请") if friend_request_windows: request_window = friend_request_windows[0] if not request_window.isActive: request_window.activate() time.sleep(1)
pass_button = pyautogui.locateCenterOnScreen("wechat_pass_button.png", confidence=0.8) if pass_button: pyautogui.click(pass_button) time.sleep(2) name_area = pyautogui.screenshot().crop((120,210,320,250)) applicant_name = name_area.to_string() remark_area = pyautogui.screenshot().crop((380,210,580,250)) apply_remark = remark_area.to_string() channel ="未知渠道" if "来自官网" in apply_remark: channel ="渠道-官网" elif "来自社群" in apply_remark: channel ="渠道-社群"
tag_service = CustomerTagService() tag_service.add_tags( customer_name=applicant_name, tags=[channel,"新客户","待跟进"] )
tag_service.set_remark( customer_name=applicant_name, remark=f"{channel}-{applicant_name}-{time.strftime('%Y%m%d')}") ai_service = AIAgentService() ai_service.assign_agent( customer_name=applicant_name, agent_id="pre_sales_default_01" ) print(f"好友申请处理完成:{applicant_name}({channel})")
while True: auto_accept_friend_request() time.sleep(30)
from chat_history_service import ChatHistoryService from ai_script_generator import AIScriptGenerator
def generate_follow_up_script(customer_id): customer_info = CustomerTagService().get_customer_info(customer_id) customer_tags = customer_info["tags"] history_needs = customer_info["history_needs"] chat_service = ChatHistoryService() recent_chats = chat_service.get_recent_chats( customer_id=customer_id, limit=3 ) formatted_chats ="\n".join([f"{msg['sender']}:{msg['content']}"for msg in recent_chats]) prompt =f""" 基于以下信息生成追单话术,要求语气亲切、贴合客户需求,提及客户过往关注的点: 1. 客户标签:{customer_tags} 2. 历史对话摘要:{formatted_chats} 3. 当前可提及的信息:工具类产品年费优惠(原价99元,现价68元),支持多设备使用 4. 核心目标:引导客户再次咨询,了解是否有进一步需求 """
ai_generator = AIScriptGenerator() follow_up_script = ai_generator.generate(prompt=prompt) return follow_up_scriptfollow_up_content = generate_follow_up_script(customer_id="cust_10086")print(f"追单话术:{follow_up_content}")