VoiceXML Example : Asterisk

Play values with SayNumber/SayDigits

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="es-ES">
 <var name="myname" expr="'borja'"/>
 <form>
  <block>
   <prompt>
    <audio src="application:SayDigits(45)"/>
    <audio expr="'application:SayNumber('+(12+4)+',f)'"/>
    <audio src="application:SayAlpha(borja)"/>
    <audio expr="'application:SayPhonetic('+myname+'borja)'"/>
   </prompt>
  </block>
 </form>
</vxml>

The VoiceXML browser will use the Asterisk applications to play specific values. The xml:lang attribut is important to set the Asterisk language.

Download : audio_app.vxml

Get an Asterisk variable value

<?xml version="1.0" ?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <form id="demo-transfer">
    <block>
      <prompt>Get an Asterisk variable value.</prompt>
    </block>
    <transfer name="getvar" bridge="true" dest="execute:get(VXML_ID)" />
    <block>
      <prompt>The value is
        <value expr="getvar$.value" />.</prompt>
    </block>
  </form>
</vxml>

The VoiceXML browser will use the prefix 'execute:' to exchange with the Asterisk channel context.

Download : transfer_get.vxml

Set an Asterisk variable

<?xml version="1.0" ?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <form id="demo-transfer">
    <block>
      <prompt>
        <prosody>Set an Asterisk variable.</prosody>
      </prompt>
    </block>
    <transfer name="toto" bridge="true" dest="execute:set(VXML_MOMO)=10"></transfer>
  </form>
</vxml>

The VoiceXML browser will use the prefix 'execute:' to exchange with the Asterisk channel context.

Download : transfer_set.vxml

Set CDR userfield

<?xml version="1.0" ?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <form id="demo">
    <block>
      <prompt>Set CDR user field.</prompt>
    </block>
    <transfer name="userfield" bridge="true" dest="execute:function(CDR(userfield))=12" />
    <transfer name="userfield2" bridge="true" dest="execute:function(CDR(userfield))+=34" />
    <block>
      <prompt>End of call.</prompt>
    </block>
  </form>
</vxml>

The VoiceXML browser will use the Asterisk function CDR() to set a value in the CDR.

Download : transfer_cdr.vxml

Log In