from db import supabase from engine.states import HANDOFF_DONE def create_support_handoff(customer_phone: str, bot_number: str, summary: str, metadata=None): payload = { "customer_phone": customer_phone, "bot_number": bot_number, "department": "support", "summary": summary, "status": "pending", "metadata": metadata or {}, } res = supabase.table("handoff_requests").insert(payload).execute() rows = res.data or [] return rows[0] if rows else None def create_support_handoff_result(flow_data: dict, summary: str): flow_data = flow_data or {} flow_data["handoff_department"] = "support" flow_data["handoff_summary"] = summary return { "next_state": HANDOFF_DONE, "flow_data": flow_data, "reply": ( "تمام، تم رفع استفسارك لفريق خدمة العملاء.\n" "هيتم التواصل معاك قريب." ), "action": { "type": "handoff", "department": "support", "summary": summary, } }