Twilio Return gathering after client press star
I'm trying to create a fallback gathering if the interpreter hangup from the conference while the client is still on the line, I have to return the gathering to the client to ask him if he wants another interpreter or disconnect
everything work perfect but, when the client pressed star, the gather said the first part of the word only, and then the call disconnected
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}/",
timeout=30,
)
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()
And here is the callback 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
Before the Action call, I have a function called after the interpreter leaves to tell the client to pressthe star
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
everything works as expected but when its come to gathering the twiml says "Press 1 to"