We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Returns string composed by audio files

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Returns string composed by audio files

Post by soso »

Hi,

I would like to create a function in javascript wich returns a message wich is composed of many audio files represents the digits number.

Exemple, I've many audio files like "0.wav", "1.wav", "2.wav", ...

If the user enter "123" on the phone number, like a "phone" field, the function returns "<audio src=".../1.wav" /><audio src=".../2.wav"><audio src=".../3.wav" />"

How do I write this code?

Thanks by advance.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code for audio files

Post by support »

Hi,

You wouldn't be able to implement this with a javascript function. However, here is an alternative IVR example of how you could implement this:

digitaudiofiles.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<var name="userentry" expr=""/>
<form id="takeinput">
<field name="userinput" type="digits">
  <prompt>
    Please enter some digits.
  </prompt>
  
  <filled>
    <assign name="userentry" expr="userinput"/>
    <goto next="#confirmdigits"/>
  </filled>
</field>
</form>

<form id="confirmdigits">
<field name="confirm" type="boolean">
<prompt>
  <foreach array="userentry.split('')" item="tmp">
    <audio expr="tmp+'.wav'"/>
  </foreach>
</prompt>

<prompt>
  If this is correct press 1, otherwise press 2.
</prompt>

<filled>
  <if cond="confirm==1">
    <prompt>
      These digits were correct.
    </prompt>
  <else/>
    <prompt>
      These digits were not correct.
    </prompt>
  </if>
</filled>
</field>
</form>
</vxml>
From this IVR example, the user first enters a string of digits such as "123". Next, when we go to our IVR tag, <foreach>, in the next field, it splits up that string of digits into an array, which allows you to play your IVR audio files in this manner:

<audio src=".../1.wav" />
<audio src=".../2.wav">
<audio src=".../3.wav" />

Hope this helps.

Regards,
Plum Support

Post Reply