Twilio会议通话中按星号后Gather语音仅播放部分即挂断的问题求助
Twilio会议通话中按星号后Gather语音仅播放部分即挂断的问题求助
我现在遇到一个Twilio语音通话的棘手问题:当口译员从会议中挂断,但客户还在线时,我需要触发一个回退的Gather交互,让客户选择是转接新口译员还是直接挂断电话。
目前大部分流程都能正常跑通,但当客户按下星号后,Gather的提示语音只播放了开头部分(比如只说到“Press 1 to”),然后通话就直接断开了,完全没法完成后续的选择交互。
下面是我的相关代码,麻烦大家帮忙看看问题出在哪:
来电处理逻辑代码
def handle_incoming_call(self, call_sid, from_number, language_code): try: with transaction.atomic(): next_interpreter = CallSelector.get_next_interpreter(language_code) conference_name = f"conferenceـ{call_sid}" conference = CallSelector.create_conference( language=next_interpreter.language, interpreter=next_interpreter.interpreter, conference_name=conference_name, ) response = VoiceResponse() response.say("Please wait while we connect you with an interpreter") dial = Dial( hangup_on_star=True, action=f"{settings.BASE_URL}/api/calls/webhook/interpreter_leave/{conference.conference_id}/", ) dial.conference( conference_name, start_conference_on_enter=True, end_conference_on_exit=False, # record=True, # recording_status_callback=f"{settings.BASE_URL}/api/calls/webhook/recording/{conference.conference_id}/", status_callback=f"{settings.BASE_URL}/api/calls/webhook/conference-status/{conference.conference_id}/", status_callback_event="start end join leave announcement", status_callback_method="POST", beep=True, participant_label="client", ) response.append(dial) self._add_client_to_conference(conference, from_number, call_sid), self._call_interpreter(conference, next_interpreter.interpreter), return response except Exception as e: logger.error(f"Call handling failed: {str(e)}", exc_info=True) return self._generate_no_interpreter_twiml()
口译员离开的回调代码(interpreter_leave)
def handel_interpreter_leave(self, conference_id: str): try: print("Interpreter leave handling started") conference = CallSelector.get_conference_by_conference_id(conference_id) response = VoiceResponse() gather = Gather( num_digits=1, action=f"{settings.BASE_URL}/api/calls/webhook/client_choice/{conference_id}/", method="POST", timeout=10, input="dtmf", ) gather.say("Press 1 to connect with a new interpreter, or press 2 to end the call.") response.append(gather) return response except Exception as e: logger.error(f"Interpreter leave handling failed: {str(e)}", exc_info=True) raise
口译员挂断后的通知逻辑代码
def handle_interpreter_hangup(self, conference_id: str, sid: str): try: print("Interpreter hangup handling started") conference = CallSelector.get_conference_by_conference_id(conference_id) self.client.conferences.get(conference.conference_sid).update( announce_url=f"{settings.BASE_URL}/api/calls/webhook/interpreter_leave_redirect/{conference_id}/" ) except Exception as e: logger.error(f"Interpreter hangup handling failed: {str(e)}", exc_info=True) raise
另外还有个奇怪的现象:如果我在最初的Dial组件里加上time_limit属性,Gather就能正常完整播放提示音并等待客户输入了。但我实在想不通这两者之间的关联,也不想靠这种临时的“偏方”解决问题,希望能找到根本原因。
备注:内容来源于stack exchange,提问作者Elabbasy00
相关产品推荐
相关产品推荐

