Question
How can I enable bidirectional media streams for PSTN calls which are part of Twilio conference calls using a TwiML App?
How to Connect Your Voice AI Agent to a Twilio Conference with Bi-Directional Media Streams Using TwiML Apps?
Product
Programmable Voice
Answer
To enable bidirectional media streams for PSTN calls with Twilio Media Streams, you need to use a TwiML Application with the <Connect><Stream> verb in a conference setup. This approach allows you to both receive audio from the caller and send audio back to the caller in real time. The recommended steps are:
- Start a conference for the call ( for example, using
<Dial><Conference>) - Add a participant to the conference via the Conference /Participants endpoint, where the
TOparameter for the participant is set toapp:<APP_SID>that will provide the next instructions - The TwiML Application should return
<Connect><Stream>, which enables the media stream
<Response>
<Connect>
<Stream url="wss://example.com/audiostream" />
</Connect>
</Response>3. Your server can then receive and send audio in real time through the media stream
Additional Information
For more details and step-by-step instructions, see Twilio’s guide on connecting a TwiML App to a Twilio Conference.