This example will set up a basic conference between two or more parties. It starts with a basic ccxml file:
<?xml version="1.0" ?> <ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml"> <eventprocessor> <!-- here we define which events we will catch, this is done with the "transition" tag --> </eventprocessor> </ccxml>
Next we need to catch incoming event and tell the VoiceXML module what to do with them. The first event is “connection.alerting”. This is fired every time a new connection (incoming call) is created.
<!-- when connection comes in, save connection ID andcreate a conference --> <transition event="connection.alerting"> <assign name="ConnectionId" expr="event$.connectionid" /> <createconference conferenceid="ConferenceId" confname="'myconference'" /> <!-- optional VXML, validating access to conference --> <dialogprepare src="Access.vxml" type="'application/voicexml+xml'" connectionid="ConnectionId" parameters="allowed confIdweb" /> </transition> <!-- When the dialog "acces.vxml" is finished preparing --> <transition event="dialog.prepared"> <assign name="dialogid" expr="event$.connection.dialogid" /> </transition> <!-- When the dialog "Access.vxml" is finished --> <transition event="dialog.exit"> <log expr="'value of allowed is: ' + event$.values.allowed" /> <if cond="event$.values.allowed == 'false'"> <disconnect connectionid="ConnectionId"/> <else /> <join id1="ConferenceId" id2="ConnectionId" duplex="full"/> <assign name="currentstate" expr="'joined'" /> <assign name="confIdweb expr="event$.values.confIdweb" /> </if> </transition>
Last, we have a <dialogprepare> can be added to enable some sort of verification. We expect two parameters to be set after the dialog “allowed” and “confIdweb”. After the “dialog.exit” event we will check the value of “allowed”. If it’s false, the connection is not allowed to enter the confernce and thus, we disconnect the connection. In the other case, the connection is joined to the conference using <join>.
The optional “duplex” argument of <join> indication of the audio flow between the two ids. It has three possible combinations:
- id1=”ConferenceId”, id2=”ConnectionId”, duplex=”full”:
the caller is able to both hear and speak into the conference. (id1 and id2 are interchangeable)
- id1=”ConferenceId”, id2=”ConnectionId”, duplex=”half”:
the caller can speaks into the conference, but can not hear it.
- id1=”ConnectionId”, id2=”ConferenceId”, duplex=”half”:
the caller can hear the conference, but can not speak into it.
<!-- When conference is created, accept the connection --> <transition event="conference.created"> <accept connectionid="ConnectionId" /> </transition>
When <createconference> is executed a new range of events are fired, like the “conference.created”. Also an <accept> MUST be called to accept the incoming call (with optional connectionid). If the connection is not accepted, <reject> can be used.
<!-- When connection is connected, start asking for authentication --> <transition event="connection.connected" > <dialogstart prepareddialogid="dialogid" connectionid="ConnectionId" parameters="allowed confIdweb"/> </transition>
Start a authentication dialog when the connection is connected.
<!-- When connection is disconnected, unjoin from and destroy the conference --> <transition event="connection.disconnected"> <unjoin id1="ConferenceID" id2="ConnectionId" /> <!-- optional --> <destroyconference conferenceid="ConferenceId" /> <exit /> </transition>
It is not necessary to unjoin the connection. This occurs implicitly by disconnecting. Also <destroyconference> implicitly unjoins any connections remaining in the conference.
When <destroyconference> is immediatly followed by an <exit>, as in this example, the conference.destroyed event, including the event’s pre- and postprocessing, will NOT be executed. So the <exit> falsely detects a still existing conference and once again try to destroy it. This may result in ‘ E> ‘ logging(s).
<!-- catching any thrown error --> <transition event="error.*"> <log expr="'Unhandled error event: ' + event$.name"/> <exit /> </transition>