Hi,
my app currently connects to the Realtime API using WebRTC.
However, I’d like to implement the function that allows the user to record a message and then send it. AFAIK WebRTC doesn’t allow that.
My idea was to also connect to that session using WebSocket, which has more controls and also allows sending audio files.
Is that possible?
If not, what solution would allow both real time talking and audio messages?
1 Like
Hi,
Yes, you’re absolutely right — WebRTC is designed for real-time communication (like voice or video calls), but it’s not intended for sending pre-recorded audio messages.
Your idea of combining WebRTC with WebSocket is spot on. It’s a common approach:
Use WebRTC for live audio/video sessions.
Use WebSocket (or even simple HTTP POST) to send recorded audio files.
Here’s how it usually works:
-
The user records an audio message using the MediaRecorder API.
-
Once recorded, the audio file is sent through WebSocket to the server.
-
Other users in the session can then receive and play back that message.
So yes — this hybrid model is totally possible and quite practical.
Alternatively, if you’re looking for a more managed solution, platforms like Twilio, Agora, or Daily.co offer both live audio and support for sending media messages.
That’s good to hear.
However, I’m not quite sure about this - how do I make both the WebRTC and WebSocket to be on one session?
There is session_id
but I’m not aware of how I can establish a WebRTC session with a specific session_id
. And when I establish a WebRTC session, I’m not aware of any session_id
in the communication.