参考例子:http://docs.voxeo.com/ccxml/1.0-final/frame.jsp?page=createcall.htm
实现的功能(步骤或者是ccxml的执行顺序):先是进入ccxml,接着是进入到voicexml进行选择某个服务的对话,结束之后传递某个变量给ccxml,然后利用ccxml来进行转接电话
注意要点:
1、由voicexml传递的参数必须在ccxml和voicexml中都有声明
2、在voicexml中的参数声明是<var name="phoneNumber" expr="session.connection.ccxml.values.phoneNumber"/>
3、在ccxml中要有状态状态转移,在这个例子中使用的是initState变量,一步一步赋值,
4、在ccxml中要有event="connection.progressing"
5、在ccxml中的dest="'tel:+14087168081'"中的电话号码参照dest的规则
6、要拨的电话号码不能说中国大陆的,座机和手机都不支持(因为使用的voxeo),这里我只是用的美国的座机电话试的,800的电话不行
7、这不是标准的ccxml,这是基于voexo上的ccxml
8、查看log的日志也需要在voexo的网页上去查看
9、我是使用skype和google voice进行的测试
下面是ccxml(使用的是voxeo的东西)
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<var name="inboundID"/>
<var name="outboundID"/>
<var name="initState" expr="'state1'" />
<var name="phoneNumber" expr="'defaultvalue'"/>
<eventprocessor statevariable="initState">
<transition state="state1" event="connection.alerting">
<log expr="'***** INBOUND CONNECTION ALERTING *****'"/>
<assign name="inboundID" expr="event$.connectionid" />
<accept connectionid="inboundID" />
<assign name="initState" expr="'state12'"/>
</transition>
<transition state="state12" event="connection.connected">
<assign name="initState" expr="'state2'"/>
<log expr="'***** voicexml excute *****'"/>
<dialogstart src="'Haitao3.vxml'" namelist="phoneNumber"/>
</transition>
<transition state="state2" event="dialog.exit">
<assign name="initState" expr="'state3'"/>
<log expr="'***** CONNECTION.CONNECTED: INBOUND *****'"/>
<if cond="event$.values.phoneNumber == 'others'">
<createcall dest="'tel:+14087168081'" callerid="'1112223333'" connectionid="outboundID" timeout="'30s'"/>
<else />
<exit/>
</if>
</transition>
<transition state="state3" event="connection.progressing">
<log expr="'***** CONNECTION.PROGRESSING *****'"/>
<assign name="initState" expr="'state4'"/>
</transition>
<transition state="state4" event="connection.connected">
<assign name="initState" expr="'state5'"/>
<log expr="'***** CONNECTION.CONNECTED: INBOUND *****'"/>
<join id1="inboundID" id2="outboundID" duplex="'full'"/>
</transition>
<transition state="state5" event="conference.joined">
<log expr="'***** CONFERENCE JOINED: INBOUND LEG TO OUTBOUND LEG *****'"/>
</transition>
<transition event="connection.disconnected">
<log expr="'***** CONNECTION.DISCONNECTED *****'"/>
<exit/>
</transition>
<transition event="error.*">
<log expr="'CRIKEY AN ERROR HAS OCCURED: (' + event$.reason + ')'"/>
<exit/>
</transition>
</eventprocessor>
</ccxml>
下面是voicexml,这里主要是有几个选项,基本上这里放的都是录音
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
<var name="phoneNumber" expr="session.connection.ccxml.values.phoneNumber"/>
<menu dtmf="true">
<prompt>
<audio src="welcome.wav">
</audio>
<enumerate>
<audio src="main1.wav"></audio>
<audio src="main2.wav"></audio>
<audio src="main3.wav"></audio>
</enumerate>
</prompt>
<choice next="#Shopping">Shopping</choice>
<choice next="#complain">complain</choice>
<choice next="#others">others</choice>
<noinput> Please say one of <enumerate/>
</noinput>
<nomatch>
<audio src="notunderstand.wav"></audio>
<audio src="main1.wav"></audio>
<audio src="main2.wav"></audio>
<audio src="main3.wav"></audio>
</nomatch>
</menu>
<form id="Shopping">
<block>
<audio src="welcome.wav"></audio>
</block>
<record name="msg" beep="true" maxtime="5s" finalsilence="1000ms" dtmfterm="true" type="audio/x-wav">
<prompt timeout="5s">
<audio src="whatbuy.wav"></audio>
</prompt>
<noinput>
<audio src="tryagain.wav"></audio>
</noinput>
</record>
<block>
<prompt>
<audio src="whatbuy.wav"></audio>
<audio expr="msg"/>.
<audio src="goodbye.wav"></audio>
<exit namelist="phoneNumber"/>
</prompt>
</block>
</form>
<form id="complain">
<record name="msg" beep="true" maxtime="5s" finalsilence="1000ms" dtmfterm="true" type="audio/x-wav">
<prompt timeout="5s">
<audio src="whatcomplain.wav"></audio>
</prompt>
<noinput>
<audio src="tryagian.wav"></audio>
</noinput>
</record>
<block>
<prompt>
<audio src="takecomplain1.wav"></audio>
<audio expr="msg"/>
<audio src="takecomplain2.wav"></audio>.
<audio src="goodbye.wav"></audio>
<exit namelist="phoneNumber"/>
</prompt>
</block>
</form>
<form id="others">
<block>
<audio src="otherselect.wav"></audio>
<audio src="goodbye.wav"></audio>
<assign name="phoneNumber" expr="'others'"/>
<exit namelist="phoneNumber"/>
</block>
</form>
</vxml>