Page 1 of 1

foreach problem

Posted: Tue Nov 04, 2008 1:13 am
by jcooper
Hi, I am trying to implement a better way to read a confirmation number back (using prosody -25% now and its not that clear).
So i came up with the bright? idea of using a foreach loop. Code is below:

Code: Select all

			<script>
				<![CDATA[
					var confirmnumber = "12345";
					
				]]>
			  </script>

		<field name="ConfCode">
			<grammar type="application/srgs+xml" root="OOConf" mode="dtmf" version = "1.0">
				<rule id="OOConf" scope="private">
					<one-of>
						<item>1</item>
						<item>2</item>
						<item>*</item>
					</one-of>
				</rule>
			</grammar>
			<prompt>
				Your confirmation number is:
				<foreach array="confirmnumber" item="digit">
					<value expr="digit"/>
				</foreach>
				<break/>
				To repeat press 1, to continue press 2, to exit the system press the star key.
			</prompt>
			<filled>
				<if cond="ConfCode=='1'">
					<clear namelist="ConfCode"/>
					<reprompt/>
					<elseif cond="ConfCode=='2'"/>
					<goto next="#Menu"/>
					<else/>
					<disconnect />
				</if>
			</filled>
		</field>
This works but the problem is that after it has finished saying the last digit (5) it does not play the remainder of the prompt. Any ideas?

Also, as a side note, if i don't do the assignment in the script tag (e.g. do a var tag) it won't read anything back. How odd is that?

Proper use of foreach tag with IVR code

Posted: Tue Nov 04, 2008 12:16 pm
by support
Hi,

I would recommend not using the IVR tag, foreach, for this purpose as once you get to the <foreach> portion of your IVR code, it will not proceed with the rest of your prompt because it expects a response from the user.

Instead, you should prepend a comma for your variable of digits. This would slow down the read back of digits to the user. For IVR example:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>

<vxml version="2.0">

<var name="fieldvalue" expr="12345"/>

<form>
<block>
<prompt>
<speak xml:lang="en-US">
<prosody rate="-25%">
<voice name="Samantha" gender="female">
<say-as type="digits"><value expr="fieldvalue.toString().replace(/(.)/g, '$1, ')"/></say-as>
</voice>
</prosody>
</speak>
</prompt>

</block>
</form>
</vxml>
Hope this sample IVR code helps.

Regards,
Plum Support

Posted: Tue Jun 02, 2009 2:29 am
by soso
Great !

Thanks.