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

Dynamically change a directory name

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
vmagic
Posts: 14
Joined: Tue Aug 08, 2006 3:20 pm

Dynamically change a directory name

Post by vmagic »

Is it possible to dynamically change a directory name in <audio src=?
If so, how?

In the example below I would like to change the value of an expression like "$lang_dir" to equal the sub-directory name "english" or "spanish". Thus changing the directory path.

<audio src="http://incentivesonline.com/ivr/$lang_dir/welcome.mp3">
<!-- Play prompt in English or Spanish.
</audio>

brent.russell
Posts: 50
Joined: Wed Oct 04, 2006 1:34 pm
Location: SOCAL
Contact:

Post by brent.russell »

You are going to have to use php to build your vxml file. example:

say_something.php

Code: Select all

<?php
print "<?xml version=\"1.0\"?>\n";
print "<vxml version=\"2.0\">\n";
?>

<form id="saysomething">
<audio src="http://incentivesonline.com/ivr/<?php print $lang_dir; ?>/welcome.mp3"> 
</form>

<?php 
// do some other php stuff.. maybe creating other forms or access a db
?>

</vxml>
In the above example you will have to make the plum server call the url to that php file. or make one of your goto tags point to this php file.

Hope that helps

Brent

bilcorry
Posts: 3
Joined: Tue Mar 13, 2007 9:31 pm

Post by bilcorry »

Or you can do a conditional:

Code: Select all

<if cond="lang=='en'">
    <!-- english -->
    <audio src="http://incentivesonline.com/ivr/en/welcome.mp3">
    </audio>
<else />
    <!-- spanish -->
    <audio src="http://incentivesonline.com/ivr/es/welcome.mp3">
    </audio>
</if>

- Bil

vmagic
Posts: 14
Joined: Tue Aug 08, 2006 3:20 pm

Dynamically change a directory name

Post by vmagic »

I was able to make it work using the following method which is something like you mentioned in your first reply. I did not include all of the script entries just the ones that were affected. Any comments about this method?

<?php
// this keeps PHP from interpolating <session /> tags in our script
ob_start(); session_start(); ob_end_clean();

echo "<?xml version=\"1.0\"?>\n";

?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

<var name="lang_dir" expr="'mp3'"/>

<assign name="lang_dir" expr="'mp3'"/>
or
<assign name="lang_dir" expr="'mp3_s'"/>

<audio expr="'http://incentivesonline.com/ivr/'+lang_dir+'/menu.mp3'">
</audio>

</vxml>

vmagic
Posts: 14
Joined: Tue Aug 08, 2006 3:20 pm

Dynamically change a directory name

Post by vmagic »

Actually I pick up the idea from one of your other forum topics called "inline variables". Thanks again.

Post Reply