WebSocket Disconnects After Returning Time Slots in Appointment Scheduling Flow

I’m building a real-time appointment scheduling system using the OpenAI Realtime API with WebSocket connections. The flow works as follows:

  1. The user requests to schedule an appointment.
  2. The AI assistant asks for the date and calls the getAvailableSlots function.
  3. The available time slots are returned and displayed to the user.
  4. The user is prompted to select a time slot.

However, the WebSocket connection disconnects (Close Code: 1000) after returning the available time slots, preventing the user from selecting a slot and proceeding to the scheduleAppointment step.

Key Observations:

  • The WebSocket connection remains open until the getAvailableSlots function completes.
  • After returning the time slots, the connection closes before the user can respond.
  • The keepAliveInterval is set to 25 seconds, but the connection still drops.
  • There are no errors in the logs, and the disconnection appears to be intentional.