fix: speak a fallback to the caller when live-operator handoff times out instead of leaving dead silence
deploy / deploy (push) Failing after 6s
deploy / deploy (push) Failing after 6s
This commit is contained in:
@@ -416,6 +416,13 @@ class AudioSocketMediaRuntime:
|
||||
return "Техникалық ақау шықты. Оператормен қосамын."
|
||||
return "Возникла техническая проблема со связью. Соединяю с оператором."
|
||||
|
||||
@staticmethod
|
||||
def _handoff_unavailable_text(language: str | None) -> str:
|
||||
normalized = str(language or "").strip().lower()
|
||||
if normalized == "kz":
|
||||
return "Кешіріңіз, дәл қазір операторлардың барлығы бос емес. Мен сұрағыңызға көмектесуді жалғастырамын."
|
||||
return "Извините, сейчас все операторы заняты и не отвечают. Я продолжу помогать вам сама, задайте свой вопрос."
|
||||
|
||||
@staticmethod
|
||||
def _should_use_emotive_ack(registration: MediaRegistration, language: str | None) -> bool:
|
||||
if not registration.voice_v2_emotive_ack:
|
||||
@@ -1895,6 +1902,19 @@ class AudioSocketMediaRuntime:
|
||||
actor.registration.voice_session_id,
|
||||
str(exc)[:500],
|
||||
)
|
||||
# The caller was already told "one moment, connecting you" -
|
||||
# leaving them in dead silence when the transfer times out is
|
||||
# worse than an AI-handled fallback, so tell them and keep going.
|
||||
if not actor.closed:
|
||||
with contextlib.suppress(Exception):
|
||||
await self._speak_reply(
|
||||
actor,
|
||||
self._handoff_unavailable_text(actor.registration.language),
|
||||
is_greeting=False,
|
||||
reply_phase="handoff_unavailable",
|
||||
)
|
||||
if not actor.closed:
|
||||
await self._set_actor_state(actor, "listening")
|
||||
|
||||
actor.handoff_task = asyncio.create_task(_run())
|
||||
return actor.handoff_task
|
||||
|
||||
Reference in New Issue
Block a user