Conferencing is common and useful voice application. A conference allows the audio of two or more callers to be bridged. Twilio's API lets you build simple conferences that just bridge audio or complex large moderated multiuser conference bridges.
Sometimes with large conferences, users need more control over who can speak, who can listen, and when the conference starts and stops. Twilio's conference features give you the ability to customize a conference to allow these more advance use cases.
By passing different attributes to the
<Conference> noun, you can change the behavior of
|mute||controls whether a participant is allowed to speak on the conference.|
|startConferenceOnEnter||indicates whether the conference starts when this particular participant joins|
|endConferenceOnExit||indicates whether the conference is destroyed after this particular participant leaves|
In this HowTo, we build an application that presents a caller with a menu and allows them to pick if they are a listener, speaker, or moderator. Based on their choice, we will return TwiML to join them to a conference with the appropriate settings.
The web server responds with
This code causes a menu to be read to the caller and waits for them to enter digits. The Gather will submit the parameter Digits back to menu.php, which will redirect to the next piece of code.
If the user pressed 1, respond with
<Response> <Dial> <Conference muted="true" startConferenceOnEnter="false"> MyRoom </Conference> </Dial> </Response>
This code enters a participant into the conference but because mute is true, they cannot speak on the conference. Because startConferenceOnEnter is false, they do not start the conference when they join. This means that if someone has not already joined the conference with "startConferenceOnEnter" set to true, participants are muted and listen to hold music.
If the user pressed 2, respond with
<Response> <Dial> <Conference startConferenceOnEnter='false'>MyRoom</Conference> </Dial> </Response>
This code enters a participant into the conference. startConferenceOnEnter is set to false so before the conference starts, other participants cannot hear this participant speak. When the conference starts, this participant can be hear by others because the muted attribute isn't specified and defaults to true.
If the user pressed 3, respond with
<Response> <Dial> <Conference startConferenceOnEnter='true' endConferenceOnExit='true' muted="false"> MyRoom </Conference> </Dial> </Response>
This code enters a participant into the conference and because startConferenceOnEnter is true (i.e. a moderator), the conference starts when this participant joins. Starting the conference stops hold music and un-mutes all participants who did not have muted="true" set. The moderator also has endConferenceOnExit="true" set. This means that when this participant leaves, the conference is ended and all other participants are kicked from the conference and their Dial verbs fall through or hit their action handlers.
For more information on conferencing, please read: