12-29-2019 10:15 AM
Hi,
I'm a little bit new to Call Studio and Java projects. It is the first time I am trying to program my own Voice Element to be used in the CVP call flow. I created a simple JAVA code and created a new class for my element, I don't think that I'm having an issue with the code itself... (also I loaded the framework.jar and some others)
But when I'm trying to run the code I'm getting always:
*** ERROR: An error occurred during initialization of the settings: AUDIUM_HOME must be defined in order for Cisco Unified CVP VXML Server to function. This is typically done by creating an environment variable whose value points to the installation directory. This directory can also be defined by specifying a Java system property named "Audium.Home" or creating an initial parameter named "AUDIUM_HOME" within the web.xml file of the CVP.war file. ***
I don't really know if I need to run the code in the Call Studio in order to test it, again, it is my first time... can anyone elaborate if the above is an issue or not?
Besides the above error, I'm not having any errors in the code itself.
Plus, how do I make the new Voice Element to appear in my Call Studio Project on the call flow designer in the elements navigation browser?
Thank you!
Best regards,
Slavik Bialik.
Solved! Go to Solution.
12-30-2019 06:52 AM
I can't tell what you've done wrong but when I compile your code and
1.copy the full package into my Studio app named MyApp1/deploy/java/application/classes/company/HttpRequest.class
2.close the MyApp1 project out of Studio
3.open MyApp1 project in Studio
4. Look under Elements/LocalElements
then I see the Test/HttpRequest element (see screenshot).
12-29-2019 10:36 AM
12-29-2019 11:31 AM
12-29-2019 11:52 AM
12-30-2019 12:31 AM
Hi,
I'm not able to do that. :(
After compiled it, I took the HttpRequest.class file and copied it to the folder project: HttpRequest/deploy/java/application/classes. Closed the project and re-opened it. And I still cannot see the object anywhere.
Also tried to open the error logs of the CVP Call Studio and I couldn't see anything there.
Here's the sample Java code:
package company; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.HashMap; import java.util.Hashtable; import com.audium.core.vfc.VException; import com.audium.core.vfc.util.VMain; import com.audium.server.AudiumException; import com.audium.server.global.ApplicationAPI; import com.audium.server.session.VoiceElementData; import com.audium.server.voiceElement.ElementData; import com.audium.server.voiceElement.ElementException; import com.audium.server.voiceElement.ElementInterface; import com.audium.server.voiceElement.ExitState; import com.audium.server.voiceElement.Setting; import com.audium.server.voiceElement.VoiceElementBase; import com.audium.server.xml.VoiceElementConfig; import org.json.*; public class HttpRequest extends VoiceElementBase implements ElementInterface { /** * @param args */ public static void main(String[] args) { } public String getElementName() { return "HttpRequest"; } public String getDescription() { return "Make HTTP Request"; } public String getDisplayFolderName() { return "Test"; } public Setting[] getSettings() throws ElementException { Setting[] cfg_settings = { }; return cfg_settings; } public ExitState[] getExitStates() throws ElementException { ExitState done = new ExitState("done", "done", "Get success"); ExitState error = new ExitState("error", "error", "Get error"); ExitState[] exitStateArray = { done, error }; return exitStateArray; } public ElementData[] getElementData() throws ElementException { return null; } protected String addXmlBody(VMain arg0, Hashtable arg1, VoiceElementData arg2) throws VException, ElementException { try { URL url = new URL("some url"); System.out.println("[HttpRequest] url: " + url); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("Accept", "application/json"); System.out.println("[HttpRequest] Response code: " + con.getResponseCode()); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8")); StringBuilder response = new StringBuilder(); String responseLine = null; while ((responseLine = br.readLine()) != null) { response.append(responseLine.trim()); } System.out.println(response.toString()); con.disconnect(); } catch (JSONException ex) { return null; } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public String[] getAudioGroupDisplayOrder() { // TODO Auto-generated method stub return null; } public HashMap getAudioGroups() throws ElementException { // TODO Auto-generated method stub return null; } }
12-30-2019 06:52 AM
I can't tell what you've done wrong but when I compile your code and
1.copy the full package into my Studio app named MyApp1/deploy/java/application/classes/company/HttpRequest.class
2.close the MyApp1 project out of Studio
3.open MyApp1 project in Studio
4. Look under Elements/LocalElements
then I see the Test/HttpRequest element (see screenshot).
12-30-2019 06:58 AM
By the way, is there a reason to create this element as a Voice element - they're usually only created if you need to interact directly with the caller on the voice browser. They're much more complex to create and get working than creating other elements.
If you're just trying to make an HttpRequest, I'd recommend creating a Decision Element with multiple exit states. Then you need not worry about sending something to the voice browser. Just save the info into Element or Session Data and use one of the Studio voice elements (like Audio) to play the info to the caller.
I'll attach a sample Decision Element that Paul Tindall of Cisco made available years back as an example.
12-30-2019 08:14 AM
Thank you very much! I was finally able to make the element appear and use it on my application and it works great.
I'll investigate what you suggested regarding the decision element, as it makes more sense not to use the voice browser for those kind of actions.
11-25-2024 02:02 AM
just a simple question ---
if we dont use main() method in the java code in the studio apps -- where the execution will start from
11-25-2024 03:49 AM
Each class contains an 'execution method' where vxmlserver starts running your code. For action elements it's doAction() , for decision elements its doDecision(), for voice elements it's addXmlBody().
VXMLServer is a web app with its own main(). So when it encounters an action element (example, if I have a custom class named ReadFile) it executes ReadFile.doAction
Look in the CVP programming guide for full explanation.
Hth
11-26-2024 12:19 AM
thank you very much .
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide