Hello, I'm still having issues, but maybe it's a larger picture issue. Here's the complete picture:
All I am trying to create a script to handle the follwoing use cases:
- i have a list of grammar items where each item is tagged with 2 attrbutes:
item: mary had a little lamb
tag: type = animal
tag: name = mary
- I want to match a caller's utterance against the grammar items and in my submission, post
- tag type
- tag name
- callerid
- sessionid
- recorded utterance
So far so simple. I can accomplish this by using a field tag etc.
Here come the problematic requirements:
- if a user hangs up right after the first utterance
- if there is a grammar match, post as described above
- if there is no grammar match, post only the recording, sessionid and callerid (i'll do some backend work on the audio)
if there is no input or match 2 times, reprompt, then
- if there is no match for the 3rd time, post the recording, session id and callerid
- if there is no input for the third time, post the sessionid and callerid
Below are my two attempts to get this dialed in, but I seem unable to satisfy all requirements.
Can you help me capture the recording in the case of a nonmatch -- then the first attempt would work.
Otherwise, I need help using <record> with a <grammar>.
Thanks
I first tried this by using a form/field which worked great except in a nomatch there is no recording queued and thus can not be posted.
<form>
<field>
<catch>
<!-- to catch a hangup without a match -->
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<submit namelist="sessionid callerid" next="
http://my.server.com/plumvoice/hangup.php"/>
</catch>
<grammar>
// grammer items here
</grammar>
<prompt>
<noinput>
Sorry, I did not hear you.
<reprompt/>
</noinput>
<nomatch>
Sorry, I did not understand you.
<reprompt/>
</nomatch>
<noinput count="3">
OK thanks - good bye.
<!-- This disconnect fires the catch above -->
<disconnect/>
</noinput>
<nomatch count="3">
OK thanks - good bye.
<!-- This disconnect fires the catch above - however, there is no recording! -->
<disconnect/>
</nomatch>
<filled> <!-- filled means there was a grammar match, fall through to next field and submit -->
</filled>
</field>
<field name="confirm">
<!-- this traps a hangup after a match -->
<catch event="connection.disconnect.hangup">
<assign name="recording" expr="word$.recording"/>
<assign name="type" expr="word.type"/>
<assign name="name" expr="word.name"/>
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<submit namelist="callerid sessionid recording name type" next="
http://my.server.com/plumvoice/response.php" method="post" enctype="multipart/form-data"/>
</catch>
<block> <!-- the user hears the thank you, -->
Thank you
<assign name="recording" expr="word$.recording"/>
<assign name="type" expr="word.type"/>
<assign name="name" expr="word.name"/>
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<submit namelist="callerid sessionid recording name type" next="
http://my.server.com/plumvoice/response.php" method="post" enctype="multipart/form-data"/>
</block>
</field>
So then I thought to get smart and use the <record> tag - especially since the documentation seems to indicate that the recorded utterance would be matched against grammar.
However - this completely does not work there appears to be zero grammar matching and the script falls through to filled, thanks me and posts the unmatched audio.
<vxml version="2.0">
<property name="sensitivity" value="0.7"/>
<property name="recordutterance" value="true"/>
<form id="one">
<record name="word" maxtime="5s" modal="false" type="audio/x-wav">
<grammar type="application/srgs+xml" root="ROOT" mode="voice">
// grammer items here
</grammar>
<!-- if the user hangs up after the first utterance, catch and post the recording -->
<!-- this does NOT appear to do a grammar match - the post does
not contain word.campaginid or word.name -->
<catch event="connection.disconnect.hangup">
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<assign name="type" expr="word.type"/>
<assign name="name" expr="word.name"/>
<submit namelist="callerid sessionid word name type" next="
http://my.server.com/plumvoice/response.php" method="post" enctype="multipart/form-data"/>
</catch>
<prompt bargein="true" timeout="5s">
<audio src="
http://my.server.com/plumvoice/sonar3.wav">ping</audio>
</prompt>
<noinput>
<clear namelist="word"/>
Please try again.
<reprompt/>
</noinput>
<nomatch>
<clear namelist="word"/>
Please try again.
<reprompt/>
</nomatch>
<nomatch count="2">
<clear namelist="word"/>
Please try again.
<reprompt/>
</nomatch>
<noinput count="3">
<clear namelist="word"/>
Thank you.
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<submit namelist="callerid sessionid" next="
http://my.server.com/plumvoice/hangup.php" method="post" enctype="multipart/form-data"/>
</noinput>
<filled>
Thank you.
<assign name="type" expr="word.type"/>
<assign name="name" expr="word.name"/>
<assign name="callerid" expr="session.telephone.ani"/>
<assign name="sessionid" expr="session.id"/>
<submit namelist="callerid sessionid word name type" next="
http://my.server.com/plumvoice/response.php" method="post" enctype="multipart/form-data"/>
</filled>
</record>
</form>
</vxml>