cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
47
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 22-02-2007 11:35:01 AM
Are there any examples, or ideas you can point me toward to create a simple 1 digit entry dtmf step but call some ecmascript prior to submission? Any examples would be useful that you can point me to.

Anything similar i should look at and any ideas on the approach, some of the VFC stuff i know, not all though.

Cheers

Subject: RE: DTMF EcmaScript
Replied by: null on 22-02-2007 09:03:58 PM
Hi Karl,

You can invoke com.audium.core.vfc.util.VMain.setScript() method when you need to call some JavaScript prior to page submission to the voice browser. For more information about this method, please refer to Audium Java API Documentation.

Thanks,

Hong

Subject: RE: DTMF EcmaScript
Replied by: null on 22-02-2007 10:49:41 PM
Thanks,

ideally i want to do a digits component, but extend it to call a custom ecmcascript. So to extend my question.

1. want to add in a script into the root (but we are using a version < 5) so there is not way to add a reference to it. So how can i do this with java api

2. Use the basic functions of the dtmf component i.e. enter 3 digits.

3. I want to create a variable, refer to a function in the script i reference (pass in the digit value captured) and get the result back

4. Then submit this result but not the digits as the final step

This is the way it really has to be done

Any insight is appreciated!

Cheers

Karl

Subject: RE: DTMF EcmaScript
Replied by: null on 24-02-2007 12:34:18 AM
Hi Karl,

As of Studio 5 and Call Services 3.6, adding JavaScript to the root document is supported by either GUI options or the Audium Java API. However, in earlier versions you can create a custom voice element that defines the JavaScript in the VoiceXML page it produces, then use the JavaScript in that page and submit the results of the JavaScript. For more details, please refer to VMain.setScript() method.

Regards,
Hong

Subject: RE: DTMF EcmaScript
Replied by: null on 26-02-2007 09:38:13 AM
So i have to serve up my javascript every time, so can't get good performance on caching right?

How can I change the existing root document prior to 3.6 and plug in my customer javascript which is important for this task. There must be a way. This specific task needs to be done in the voice browser not J2EE server otherwise I would do it.

Cheers

Subject: RE: DTMF EcmaScript
Replied by: null on 27-02-2007 03:45:43 PM
Hi Karl,

Regarding caching, please note that by using Call Services, very little caching is actually done by the voice browser since VoiceXML pages are generated dynamically for each request. The root document page is cached by the voice browser, but only for the duration of the call - each new call will still generate a new root document. So the efficiency savings in putting a JavaScript function in the root document would be gained from parsing of the JavaScript once as opposed to in each page. In most cases the savings in efficiency is minimal.

There is no supported way to add a custom JavaScript to the root document prior to Call Services 3.6. Due to customer interest in this and the fact that there were no workarounds to allow it, this new feature was added as of Call Services 3.6.x. So your best bet is to upgrade to Call Services 3.6.x.

Hope this helps.

Subject: RE: DTMF EcmaScript
Replied by: null on 02-03-2007 03:10:33 PM
Can someone provide a simple example of a "ecmascript" being called, and result put into variable and submitted back.

Any close examples, and actual examples as I can't find any.

Cheers and Appreciated

Subject: RE: DTMF EcmaScript
Replied by: null on 02-03-2007 07:30:37 PM
Hi Karl,

While our sample code does not currently include an example of this particular scenario, we would be glad to describe how this can be implemented:

1) The only way to include Javascript in a VoiceXML page is to write a voice element. The Programmer Guide explains how to build a voice element and there are sample voice elements available from AudiumCentral.

2) To add a page scoped variable to the VoiceXML page, the [b:67f1ba1a8a]VMain.add(String, String, boolean)[/b:67f1ba1a8a] method is used. Note that this variable will automatically be added to any namelist of a submit you do in your page, so you do not need to explicitly add it yourself.

3) To define a page-scoped Javascript in your page, the [b:67f1ba1a8a]VMain.setScript(Vaction)[/b:67f1ba1a8a] method is used. A VAction that encapsulates the Javascript is created using the [b:67f1ba1a8a]VAction.getNew(VPreference, VAction.SCRIPT, MyJavascriptInAString)[/b:67f1ba1a8a] method. The string passed in the last parameter should contain the full Javascript function that you want to include in the VoiceXML page. That Javascript function should assign some value to the VoiceXML variable declared in step 2.

4) Since any submit will contain the page-scoped variable, you can then get at that variable in Java code by accessing the HTTP parameter passed in the Hashtable you get from the addXmlBody method of the voice element like so: [b:67f1ba1a8a]params.get("MyPageScopedVoiceXMLVariableName")[/b:67f1ba1a8a].

Presto, you are done. Hope this helps.

Elam

Subject: RE: DTMF EcmaScript
Replied by: null on 05-03-2007 09:00:34 PM
Thanks,

Got all that and understood. What i want is to retrieve this value in an action component and map to session variable?

params.get("MyPageScopedVoiceXMLVariableName").

Surely i don't need to do the above? Some guidance/advice.

Cheers

Subject: RE: DTMF EcmaScript
Replied by: null on 06-03-2007 03:11:29 PM
OK,

I have a script embedded, processing the result, result passed back to the object as

13:54:05,ScriptObject_01,data,result,testing123

What i want is to be able to refer to the ScriptObject_01.result property i.e. make this a scratch type variable.

I can though push it into a result variable though

Cheers

Subject: RE: DTMF EcmaScript
Replied by: null on 06-03-2007 08:15:23 PM
Hi Karl,

If all you need is to submit the variable set by JavaScript then VMain.add(String, String, boolean) method will be enough. If you want to retrieve the value and set to a session variable, then do the following in the addXmlBody method:

theVoiceElementData.setSessionData("MyPageScopedVoiceXMLVariableName", params.get("MyPageScopedVoiceXMLVariableName"));

Where theVoiceElementData is passed by addXmlBody method.

Hope this helps.

John

Subject: RE: DTMF EcmaScript
Replied by: null on 11-03-2007 04:48:55 PM
Cool, thanks, its certainly helped!
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links