Author Message
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
I am trying to build a dynamic prompt, by reading a url from a database.


>>
public void updatePrompt(SCESession mySession) {
   com.avaya.sce.runtime.Format format = null;
      IVariable var = mySession.getVariable(IProjectVariables.GET_OPTIONS);
      IComplexVariable cplx = var.getComplexVariable();
      ICollection coll = var.getCollection();
      
      coll.reset();
      while(coll.hasMore()) {
         coll.next();
         String phraseName = cplx.getField(IProjectVariables.GET_OPTIONS_FIELD_NAME).getStringValue();
         int id = cplx.getField(IProjectVariables.GET_OPTIONS_FIELD_MYOPTION).getIntValue();
         
         add(1, new com.avaya.sce.runtime.PhraseVariableElement(phraseName ,com.avaya.sce.runtime.PhraseVariableElement.Type.AUDIO_URL,false));
         add(1, new PromptElement(PromptElement.TEXT, "press"));
         add(1, new PromptElement(PromptElement.TEXT, String.valueOf(id)));
   
      }

      coll.reset();
      coll.next();

I am supposed to get the audio, then the word press and then the id.
if instead of the phraseName I insert "getOptions:NAME" Ithe prompt reads the entire data set . I am using the variable phraseName instead I am getting an error at runtime in the application simulator :
"Unable to get session variable: http://10.96.0.5/hanaya.wav", Language (en-us), Gender (Female)"
what am I doing wrong?
ShwetaBehere
Joined: Dec 23, 2013
Messages: 136
Offline
You should add tracing to your application and check if you are getting the required values for the variables that you are using. Look at the trace log for details.
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
I am receiving the correct value for the URL , http://10.96.0.5/hanaya.wav, but I am still receiving the error : unable to get session variable ( it looks as if I am defining the variable incorrctly - or some format is missing)

when I specify the entire set in this format:"getOptions:NAME" where getOptions is the dbconnection,
it does read all the records with no error

WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I don't quite understand your problem. Can you show some code snippet or logs?
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
I would like the prompt to play a number of phrases, one after the other , where the URL of the phrases is dynamically retrieved from a database table at runtime.
In the code snippet attached to the Oct28 posting,
GET_OPTIONS (getOptions) is the name of the database connection file, and the name of the complex variable that receives the values retrieved from the database.
The field NAME contains the URL of the wav file and the field ID contains a number.
When I am using the string variable phraseName to assign the value of the URL for each loop, I am getting an error

"Unable to get session variable http://10.96.0.5/hanaya.wav -

but this is exactly the value of the URL as retrieved from the database.

WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Using "getOptions:NAME" is the right way not the phrase name because the PhraseVariableElement is expecting the variable:field name instead of the actually value. Internally, it is trying resolve the variable/field name to a value. That's why you are getting the error trying to get a variable with "http://10.96.0.5/hanaya.wav" as the name, which doesn't exist.
I don't know why you are writing Java code. You could have done this in the UI using the data node to check the collection and set the next item and loop back to the prompt, which has the Phrase variable setup.
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
Thanks for the reply, I am going to try it in UI. The reason I used the java code is I wanted to make this promp part of a prompt and collect node - I am fairly new to Dialog Designer and I not sure yet how to do this correctly. Is there a sample I could use?
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The ArrayExample sample app that comes in the release bundle is very close to what you need.
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
I would like to k now how to do this using the PromptElement and Format. I want to be able to read for each loop of the collection a url field and an integer from the database - and use this prompt in a prompt and collect node.
I am having a problem with the field name /value for the url - which I don;t know how to fix. Here is the code:

public void updatePrompt(SCESession mySession) {
      
      IVariable var = mySession.getVariable(IProjectVariables.GET_OPTIONS);
      IComplexVariable cplx = var.getComplexVariable();
      ICollection coll = var.getCollection();
      Format f = new Format();
      f.add(Format.FORMAT,Format.FMT_FILEURL);
      coll.reset();
      while(coll.hasMore()) {
         coll.next();
         int id = cplx.getField(IProjectVariables.GET_OPTIONS_FIELD_ID).getIntValue();
         String vname = cplx.getField(IProjectVariables.GET_OPTIONS_FIELD_NAME).getStringValue();
         add(1, new PromptElement(PromptElement.VARIABLE_TEXT, "vname" ,f));
         add(1, new PromptElement(PromptElement.TEXT, "press"));
         add(1, new PromptElement(PromptElement.TEXT, String.valueOf(id)));
      }
      
      // reset collection for ot;hers
      coll.reset();
      coll.next();
   }
}
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
The Format.FMT_FILEURL is going to try to open the "value" as a text file or assume it is a wave file.

What is the value of "vname"? is it a variable or just a string value?
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
vname is the string where I am bringing the value of the URL - that I am getting from the database:
String vname = cplx.getField(IProjectVariables.GET_OPTIONS_FIELD_NAME).getStringValue();
I understand this is the problem - but I don't know how to bring the NAME field from the collection one at a time, not the entire collection.
It works with the ID field , which is a text field,
but I can't get the NAME field right.
When I used the PhraseVariableElement - I could only use

getOptions:NAME - and that would get me the entire collection , n times.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
What does the url point to? A wav or .txt file or do you want to the user to hear the url spoken out?

That is what is the caller supposed to hear?
DanielaBanin
Joined: Nov 6, 2013
Messages: 86
Offline
The url points to a wav file. I would like the user to hear the wav file.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
Okay no I understand what you are trying to do.

My next question is given the code below what are you experiencing? What behavior do you see and what is the generated vxml for that node withthe prompt.
ManievanderMerwe
Joined: Sep 21, 2007
Messages: 0
Offline
Just some suggestion here... I am also using dynamic promts, and you need to ensure that the .wav files are at the correct location.

If you use this URL - http://10.96.0.5/hanaya.wav

If the server 10.96.0.5 is a tomcat server the hanaya.wav file needs to be in the webapps directory which is the root document directory.
Go to:   
Mobile view