Page 1 of 1

Implement a logic for multiple results of searching

Posted: Mon Oct 08, 2007 2:38 pm
by viktoriya
Hi,

If somebody tried to implement something similar ?


Using dtmf user inputs last name, after search, retrieving data consists of three last names with the same sequence of digits from keypad.

Assume our database has persons with the last names of ‘Randall’, ‘Sanderson’, and ‘Pane’,
where all of them are related to enter 7-2-6-3 for the last name search.
We want our system to provide the following logic:
" if you entered Randall, say 'yes', if not, say 'no' "
In case of false:" if you entered Sanderson, say 'yes',
if not, say 'no' "
In case of false: " if you entered Pane, say 'yes',
if not, say 'no' "
In case of false: " Sorry, we don't have a person with entered last name. "

Thank you, Viktoriya

Implement logic for multiple results of searching with IVR

Posted: Mon Oct 08, 2007 3:30 pm
by support
Hi,

Using your IVR application server scripting language (php, asp, jsp), you need to convert the 4 digits into all of the permutations of letters they could represent. You can then use these permutations in a query against your database Or you could add another column to your database that is the 4 digit string that matches the name.

Regards,
Plum Support

Posted: Tue Oct 09, 2007 2:48 pm
by viktoriya
Thank you for your advice.
I have a question. If searching elements thru xml such as all matching last names and prompting to the user back for a selection can't be done inside of vxml or it should be done as querying in my asp, php files ?

Thank you, Viktoriya

IVR code to query a db to come up with a dynamic list

Posted: Tue Oct 09, 2007 3:27 pm
by support
Hello,

The trick here is to understand that VoiceXML is really only used to collect and present information to the user. If you want to allow a user to search for last names you need to break your IVR code out into two pages. The first page will collect the 4 digits from the user and <submit> them to your IVR application server:

index.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
	<form>
		<field name="lastname" type="digits?length=4">
			<prompt>Using your keypad, please enter the first four letters of the last name of the person you are looking for.</prompt>
			<filled>
				<submit next="search.php" namelist="lastname" method="post"/>
			</filled>
		</field>
	</form>
</vxml>
The second page will accept the post, query your database for a match and then present the list of names to the caller. In the IVR code example below we are just using a static list of names. Your IVR code would query a database to come up with a dynamic list:

search.php

Code: Select all

<?php
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
   <var name="name"/>
   <form>
<?php
// YOUR DATABASE QUERY WOULD GO HERE TO SEARCH FOR THE LIST OF NAMES TO LOOP THROUGH
$names = Array('Randall', 'Sanderson', 'Pane');
foreach ($names as $count=>$name) {
?>
      <field name="field_<?=$count?>" type="boolean">
         <prompt>If you entered <?=$name?>, say yes, if not, say no.</prompt>
         <filled>
            <if cond="field_<?=$count?>">
               <assign name="name" expr="'<?=$name?>'"/>
               <goto next="#playname"/>
            </if>
         </filled>
      </field>
<?php
}
?>
   </form>

   <form id="playname">
      <block>You selected <value expr="name"/></block>
   </form>
</vxml>

In case you are not familiar with PHP, the output of the IVR example above would be as follows:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
   <var name="name"/>
   <form>
      <field name="field_0" type="boolean">
         <prompt>If you entered Randall, say yes, if not, say no.</prompt>
         <filled>
            <if cond="field_0">
               <assign name="name" expr="'Randall'"/>
               <goto next="#playname"/>
            </if>
         </filled>
      </field>
      <field name="field_1" type="boolean">
         <prompt>If you entered Sanderson, say yes, if not, say no.</prompt>
         <filled>
            <if cond="field_1">
               <assign name="name" expr="'Sanderson'"/>
               <goto next="#playname"/>
            </if>
         </filled>
      </field>
      <field name="field_2" type="boolean">
         <prompt>If you entered Pane, say yes, if not, say no.</prompt>
         <filled>
            <if cond="field_2">
               <assign name="name" expr="'Pane'"/>
               <goto next="#playname"/>
            </if>
         </filled>
      </field>
   </form>
   <form id="playname">
      <block>You selected <value expr="name"/></block>
   </form>
</vxml> 
Regards,
Plum Support

Posted: Thu Oct 11, 2007 9:03 am
by viktoriya
Thank you very much that you clarified for me this point.
How can I connect to my database inside of second vxml before actually querying ?

One more question, I've used so far only xml file as a substition of database and used ECMAscript.
I connect to my xml file by :
<data name="XMLOffender" src="http://webhosting.voxeo.net/26452/offender_system.xml" />
<assign name="document.XMLOffender" expr="XMLOffender.documentElement"/>

Later on, I use DOM model to find all last names for exe. and store into array. Next, make comparison of user's input of last name with elements of an array. Create another array, based on matched search. Give prompts to user.

Can this process work also ? I don't need to update data in xml, only find elements. So, I'd like to ask again if this logic can be done by using only ECMAsript inside of VXML if all processes apply only at client side ?

Thank you.

IVR script needed to understand user's issue

Posted: Thu Oct 11, 2007 11:02 am
by support
Hi,

We are not sure of what you want to do. Could you post a URL to your IVR application script here?

Regards,
Plum Support