File size: 1,105 Bytes
df124d2
e995f68
df124d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e995f68
df124d2
 
 
 
 
 
 
 
 
 
02fbdc7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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,
        }
    }