Update handoff/support.py
Browse files- handoff/support.py +34 -34
handoff/support.py
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
from db import supabase
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
def
|
| 5 |
-
payload = {
|
| 6 |
-
"customer_phone": customer_phone,
|
| 7 |
-
"bot_number": bot_number,
|
| 8 |
-
"department": "
|
| 9 |
-
"summary": summary,
|
| 10 |
-
"status": "pending",
|
| 11 |
-
"metadata": metadata or {},
|
| 12 |
-
}
|
| 13 |
-
res = supabase.table("handoff_requests").insert(payload).execute()
|
| 14 |
-
rows = res.data or []
|
| 15 |
-
return rows[0] if rows else None
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def
|
| 19 |
-
flow_data = flow_data or {}
|
| 20 |
-
flow_data["handoff_department"] = "
|
| 21 |
-
flow_data["handoff_summary"] = summary
|
| 22 |
-
|
| 23 |
-
return {
|
| 24 |
-
"next_state": "HANDOFF_DONE",
|
| 25 |
-
"flow_data": flow_data,
|
| 26 |
-
"reply": (
|
| 27 |
-
"تمام، تم رفع
|
| 28 |
-
"هيتم التواصل معاك قريب
|
| 29 |
-
),
|
| 30 |
-
"action": {
|
| 31 |
-
"type": "handoff",
|
| 32 |
-
"department": "
|
| 33 |
-
"summary": summary,
|
| 34 |
-
}
|
| 35 |
}
|
|
|
|
| 1 |
+
from db import supabase
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def create_support_handoff(customer_phone: str, bot_number: str, summary: str, metadata=None):
|
| 5 |
+
payload = {
|
| 6 |
+
"customer_phone": customer_phone,
|
| 7 |
+
"bot_number": bot_number,
|
| 8 |
+
"department": "support",
|
| 9 |
+
"summary": summary,
|
| 10 |
+
"status": "pending",
|
| 11 |
+
"metadata": metadata or {},
|
| 12 |
+
}
|
| 13 |
+
res = supabase.table("handoff_requests").insert(payload).execute()
|
| 14 |
+
rows = res.data or []
|
| 15 |
+
return rows[0] if rows else None
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def create_support_handoff_result(flow_data: dict, summary: str):
|
| 19 |
+
flow_data = flow_data or {}
|
| 20 |
+
flow_data["handoff_department"] = "support"
|
| 21 |
+
flow_data["handoff_summary"] = summary
|
| 22 |
+
|
| 23 |
+
return {
|
| 24 |
+
"next_state": "HANDOFF_DONE",
|
| 25 |
+
"flow_data": flow_data,
|
| 26 |
+
"reply": (
|
| 27 |
+
"تمام، تم رفع استفسارك لفريق خدمة العملاء.\n"
|
| 28 |
+
"هيتم التواصل معاك قريب."
|
| 29 |
+
),
|
| 30 |
+
"action": {
|
| 31 |
+
"type": "handoff",
|
| 32 |
+
"department": "support",
|
| 33 |
+
"summary": summary,
|
| 34 |
+
}
|
| 35 |
}
|