cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
408
Views
4
Helpful
3
Replies

Couldn't capture user input at menu using vfc

sreekanth47
Level 4
Level 4

Hi all, I created a menu using VMenuFiled class , but couldn't able to capture the input at menu, and I'm not aware of  concept of scratch data in voice element, what it does exactly? it represents the current state of a call this is what I knew about this.

the below peace of code in addXMLBody(***) method,  I used in my class for getting scratch data.

VPreference pref = ved.getPreference();

String submittedMainFieldName =(String) ved.getScratchData(AUDIO_NAME); where AUDIO_NAME I declared as constant.

I set the value in scratch data at the end of my class like

ved.setScratchData(AUDIO_NAME, "the_main_field_name");

to capture user dtmf at menu, I used the below code.

String menuOption = null;

         if (submittedMainFieldName != null) {         

          menuOption = (String)reqParameters.get(submittedMainFieldName);

         }

if(submittedMainFieldName==null||submittedMainFieldName.equals("1")){

// code to built munu and prompt menu options.

}

I got confused, why scratch data returns null value every time.

What data we need to set into scratchdata. In my requirement, I need to repeat menu , if the caller press 1, but I didn't able to capture user input at the menu. How to handle this , I attached  my code. Can you please help me out. Thanks in advance.

1 Accepted Solution

Accepted Solutions

janinegraves
Spotlight
Spotlight

*Below is the VXML Code that your element creates.

*

So, your addXMLBody will be getting back "*myMenu" with the value "1" or

"2" *in the reqParameters hashtable .

Also, you are setting scratchspace variable named AUDIO_NAME ("audio")

with the literal words ("the_main_field_name") - not the value of the

field name.

So, if you execute getScratchSpace(AUDIO_NAME) then it'll have the value

null (1st time executing) or "the_main_field_name" (2nd time executing).

You might instead *setScratchSpace("Stage1Complete", "true") - to make

it something more intuitive.*

Below is the VXML Code that your element creates the first time.

  • <submit next="/CVP/Server" method="post" namelist="myMenu" />*

View solution in original post

3 Replies 3

janinegraves
Spotlight
Spotlight

Please try reading carefully the section on Voice Elements in the CVP

Programming Guide.

Your voice element's addXMLBody will be called multiple times - once to

create VXML, then to examine the response from the gateway, perhaps to

create more VXML, and then to examine that response, and to store

results into Element and/or Session data.

Scratch Space is a way to have VXML Server store information so that

each time your addXMLBody is called, it knows what stage of the voice

element it is in. It's like your addXMLBody is a state machine and using

Scratch Space to store the state you number that you just executed.

If the addXMLBody tries to retrieve something from scratch space and

it's null, then it's the first time you've executed - so you create the

first VXML page to ask the caller toenter something. If you'll need to

examine the caller's response, then end with return null. But before

ending with return null, set something into scratch space, so next time

you'll know that you've completed step 1 (example, set the variable

named *stageCompleted *to the value 1). By the way,*return null

*causes VXML Server to come back to your addXMLBody upon the next http

request from the gateay.

If you try to retrieve stageCompleted from scratch space and it has the

value 1, then you know this is the 2nd time into your addXMLBody and you

expect the caller's response. If it's null, then it's the first time

you've been called and you need to create the first VXML page.

janinegraves
Spotlight
Spotlight

*Below is the VXML Code that your element creates.

*

So, your addXMLBody will be getting back "*myMenu" with the value "1" or

"2" *in the reqParameters hashtable .

Also, you are setting scratchspace variable named AUDIO_NAME ("audio")

with the literal words ("the_main_field_name") - not the value of the

field name.

So, if you execute getScratchSpace(AUDIO_NAME) then it'll have the value

null (1st time executing) or "the_main_field_name" (2nd time executing).

You might instead *setScratchSpace("Stage1Complete", "true") - to make

it something more intuitive.*

Below is the VXML Code that your element creates the first time.

  • <submit next="/CVP/Server" method="post" namelist="myMenu" />*

Thank you very much Janine Graves. Now I'm able to capture user input,