Update call_connection_manager.py
Browse files- call_connection_manager.py +1 -33
call_connection_manager.py
CHANGED
@@ -5,7 +5,6 @@
|
|
5 |
#
|
6 |
import json
|
7 |
import os
|
8 |
-
import time
|
9 |
from typing import Any, Dict, List, Optional
|
10 |
from loguru import logger
|
11 |
|
@@ -21,7 +20,6 @@ class CallFlowState:
|
|
21 |
self.voicemail_message_left = False
|
22 |
self.call_terminated = False
|
23 |
self.participant_left_early = False
|
24 |
-
self.silence_prompt_count = 0 # Track silence prompts
|
25 |
|
26 |
def set_operator_dialed(self):
|
27 |
self.dialed_operator = True
|
@@ -67,12 +65,6 @@ class CallFlowState:
|
|
67 |
def set_participant_left_early(self):
|
68 |
self.participant_left_early = True
|
69 |
|
70 |
-
def increment_silence_prompts(self):
|
71 |
-
self.silence_prompt_count += 1
|
72 |
-
|
73 |
-
def reset_silence_prompts(self):
|
74 |
-
self.silence_prompt_count = 0
|
75 |
-
|
76 |
class SessionManager:
|
77 |
def __init__(self):
|
78 |
self.session_ids = {"operator": None, "customer": None, "bot": None}
|
@@ -281,28 +273,4 @@ class CallConfigManager:
|
|
281 |
return ""
|
282 |
space_prefix = " " if preposition else ""
|
283 |
space_suffix = " " if preposition else ""
|
284 |
-
return f"{space_prefix}{preposition}{space_suffix}{customer_name}"
|
285 |
-
|
286 |
-
async def log_call_summary(self, start_time: float, session_manager: SessionManager, caller_number: str, dialed_number: str, customer_name: str):
|
287 |
-
"""Log call summary to a file."""
|
288 |
-
end_time = time.time()
|
289 |
-
duration = end_time - start_time
|
290 |
-
silence_prompts = session_manager.call_flow_state.silence_prompt_count
|
291 |
-
summary = {
|
292 |
-
"call_start_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(start_time)),
|
293 |
-
"call_end_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(end_time)),
|
294 |
-
"duration_seconds": round(duration, 2),
|
295 |
-
"caller_number": caller_number,
|
296 |
-
"dialed_number": dialed_number,
|
297 |
-
"customer_name": customer_name,
|
298 |
-
"silence_prompts_triggered": silence_prompts,
|
299 |
-
"call_terminated_by_bot": session_manager.call_flow_state.call_terminated,
|
300 |
-
"participant_left_early": session_manager.call_flow_state.participant_left_early
|
301 |
-
}
|
302 |
-
log_file = "/home/user/call_summary.log"
|
303 |
-
try:
|
304 |
-
with open(log_file, "a") as f:
|
305 |
-
f.write(json.dumps(summary) + "\n")
|
306 |
-
logger.info(f"Call summary logged to {log_file}")
|
307 |
-
except Exception as e:
|
308 |
-
logger.error(f"Failed to log call summary: {e}")
|
|
|
5 |
#
|
6 |
import json
|
7 |
import os
|
|
|
8 |
from typing import Any, Dict, List, Optional
|
9 |
from loguru import logger
|
10 |
|
|
|
20 |
self.voicemail_message_left = False
|
21 |
self.call_terminated = False
|
22 |
self.participant_left_early = False
|
|
|
23 |
|
24 |
def set_operator_dialed(self):
|
25 |
self.dialed_operator = True
|
|
|
65 |
def set_participant_left_early(self):
|
66 |
self.participant_left_early = True
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
class SessionManager:
|
69 |
def __init__(self):
|
70 |
self.session_ids = {"operator": None, "customer": None, "bot": None}
|
|
|
273 |
return ""
|
274 |
space_prefix = " " if preposition else ""
|
275 |
space_suffix = " " if preposition else ""
|
276 |
+
return f"{space_prefix}{preposition}{space_suffix}{customer_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|