Wiki

« Back to JeevesTheVoiceRec...

JeevesTheVoiceRecRobot-Designer

Note: The CUAE server should be added as a H323 gateway to the CUCM and CUCM server should be added as a H323 gateway to the CUAE.

Create a route pattern e.g 10XXXX associated with the H323 gateway (CUAE server)in CUCM. Trigger Ip Phone number should belong to the route pattern.

Requirements #

The development machine where you are creating this application should have the following installed.

  1. CUAE Developer Tools (Etch framework and CUAE Designer)
  2. Speech Recognition Server added to the CUAE (setup instructions included in this tutorial)
  3. Speech Recognition License Servers added to the CUAE (setup instructions included in this tutorial)

Build the Project#

Create the Project

1. Open CUAD designer. Goto File->New Project

2. Create a project called JeevesTheVoiceRecRobot_CUAD.

3. When creating a new project, the Designer will prompt you to name first script and to select a triggering event for that script. For this example we will just go ahead and keep the default script name 'script1', but we are going to select a specific triggering event. For this application select the 'Metreos.CallControl.IncomingCall' event:

Add Global Variables#

1. We will be using two global variables in this application. Global variables can be accessed by any event throughout your application. We will follow the convention of naming global variables with the prefix 'g_'. To add a global variable, click on script1 in the Explorer Toolbox on the left hand side. R-click on the Variables folder and select Add New Item. In this manner, add two variables called g_callId and g_connectionId.

Handle OnIncomingCall #

Add a Local Variable#

1. The designer canvas has a local variables tray, which is hidden by default. You can toggle the tray on and off hidden by either selecting View > Variables Tray or R-clicking on canvas and clicking Variable Tray. Click on the OnIncomingCall tab and perform one of these two actions. A tray appears in the bottom of OnGotRequest canvas with the message "(tray empty)".

2. Now we want to add our local variable. R-click on the Variables Tray and select Add New Item. Call the new variable callId. A Properties toolbox appears on the bottom right hand side of the screen. Go to InitializeWith and select CallId. This is the unique callId that is passed in with the event OnIncomingCall.

Add Answer Call#

1. The first thing we want to do is answer the call that triggered our application. Goto the Toolbox on the top right hand side and select Call Control. Locate the action AnswerCall.

2. Drag and drop AnswerCall onto the OnIncomingCall canvas. Since this is the first action on the canvas, the Designer will automatically connect it to the Start icon. But in the future we will have to make this connection manually.

3. AnswerCall takes in a callId and returns a CallId and ConnectionId. We will save these return values into the global variables, g_callId and g_connectionId, that we have already created. Select AnswerCall by clicking on the icon. It will be highlighted by a green box. Navigate to the Properties toolbox and set the following parameters:

Add Hangup#

1. Should AnswerCall be unsuccessful, we want to hang up on the call and end the application. Locate and expand the CallControl menu in the Toolbox. Drag and drop Hangup onto the OnIncomingCall canvas. Now we need to add a connection from AnswerCall to Hangup. Hover your mouse over the center of AnswerCall until it becomes a hand icon, then click and drag towards Hangup. An arrow should connect the two, pointing at Hangup. We will use the 'default' condition that is associated with the connection automatically.

2. Highlight Hangup and navigate to the Properties toolbox. Set the parameter CallId to type variable and value callId (the local variable we created).

Add EndScript#

1. Once we hang up the call, we want to end the script. Goto the Toolbox and expand Application Components. Find EndScript and drag and drop it onto the canvas. Connect it to the Hangup icon.

Add Play#

1. Now we have implemented the action we want our application to take if it is unable to answer the incoming call. Now we want to implement a course of action for if it is able to answer the call. First we want it to play a message, so find and expand the Media Control tab in the toolbox. Drag and drop Play onto the canvas and connect it to AnswerCall. Click on the label 'default' that automatically appears, and change it to 'Success' from the drop down list. That way, it will only try to play a message if AnswerCall was successful. Note that two event tabs, OnPlay_Complete and OnPlay_Failed, are added at the top of the canvas.

2. Select Play and go to its Properties toolbox. Set the following parameters:

Parameter Type Value
ConnectionId variable g_connectionId
Prompt1 string Please say hi, how are you, or bye and wait for a response.
UserData string begin_voice_rec

Add EndFunction#

1. Once Play is complete, we are done implementing OnIncomingCall. However, since we still have to implement OnPlay_Complete and OnPlay_Failed, we don't want to end our application script, so we will add an EndFunction instead. Go to the Toolbox and expand the Application Components tab. Drag and drop EndFunction onto the OnIncomingCall canvas. Connect it to Play and keep the 'default' connection link.

Handle OnPlay_Complete#

Add a Local Variable#

1. First we want to add a local variable called userData to the OnPlay_Complete event. Click on the tab labeled OnPlay_Complete on the top of the screen and you will see the OnPlay_Complete canvas. Show the Variables Tray and R-click and select Add New Item. Call the new variable userData and in its Properties toolbox, set InitializeWith to UserData from the drop down menu.

Add Switch#

1. We added a play action when we were implementing OnIncomingCall. Later on we will add another Play action. In order to differentiate between the two, we will have different values for the userData parameter. Since we want to take different courses of action in the two different cases, we will add a Switch. Go to the Toolbox and expand Application Components. Find Switch and drag and drop it onto the canvas.

2. Go to the Properties toolbox and set the parameter SwitchOn to type variable and value userData.

Add VoiceRecognition#

1. If this is the first time we have executed OnPlay_Complete, the userData will be set to begin_voice_rec, and we will want to implement the voice recognition part of the application. If this is the second time we have executed OnPlay_Complete, we will want to hang up and exit the application. We will implement the first case now, so go to the Toolbox and expand MediaControl. Drag and drop Voice Recognition onto the OnPlay_Complete canvas. Connect it to Switch. Manually type in the condition as 'being_voice_rec'. Note the addition of OnVoiceRecognition_Complete and OnVoiceRecognition_Failed event tabs.

2. Set the following parameters in the VoiceRecognition toolbox. Note that later in the example we will be creating the file jeeves.grxml:

Parameter Type Value
ConnectionId variable g_connectionId
Grammar1 string jeeves.grxml
Timeout string 1000
UserData string none

Add EndFunction#

1. Since at this point in the application we still want to execute OnVoiceRecognition_Complete, we don't want to add an EndScript. We want to add an EndFunction instead, so go to the Toolbox and expand the Application Components tab. Drag and drop EndFunction onto the canvas and connect it to VoiceRecognition.

Add Hangup#

1. Now that we have taken care of the first condition of our Switch, let's go back and implement the second branch. In this case we are finished with the application, and just need to hang up the phone and end the script. So go to the Toolbox and expand Call Control. Drag and drop Hangup onto the OnPlay_Complete canvas and connect it to Switch. Manually type in the condition exit_app.

2. In the Properties toolbox of Hangup, set CallId to type variable and value g_callId.

Add EndScript#

1. Go to the Toolbox and expand Application Components. Drag and drop EndScript onto the OnPlay_Complete canvas and connect it to Hangup.

Handle OnPlay_Failed#

Add Hangup#

1. Now we are going to handle OnPlay_Failed, so click on the event tab at the top of the canvas. This will execute if for some reason we could not play the audio stream to the phone. Since we cannot proceed with the rest of the application, the best course of action would be to hang up and end the script. So go to the Toolbox and expand Call Control. Drag and drop Hangup onto the OnPlay_Failed canvas.

2. Go to the Properties toolbox of Hangup and set the parameter callId to the type variable and the value g_callId.

Add EndScript#

1. Go to the Toolbox and expand Application Components. Drag and drop EndScript onto the OnPlay_Failed canvas and connect it to Hangup.

Handle OnVoiceRecognition_Complete#

Add Local Variables#

1. When voice recognition has been completed, we want the application to play one of three different messages, depending on what the user said. Click on the OnVoiceRecognition_Complete tab at the top of the canvas and view the Variables Tray. We need a local variable to hold the result data from the VoiceRecognition action, so R-click on the Variables Tray and select Add New Item. Call the new variable resultList, and in its Properties box set InitializeWith to VR_XMLResult from the drop down list.

2. R-clik on the Variables Tray again and create a variable called meaning. Set its InitializeWith parameter to Meaning from the drop down list.

Add Switch#

1. Depending on what the user said to the phone, we want to play different messages back. So go to the Toolbox and expand Application Components. Drag and drop Switch onto the OnVoiceRecognition_Complete canvas.

2. Set the parameter SwitchOn to the type variable and the value meaning.

Add Play#

1. Now we want to add the first Play action. Go to the Toolbox and expand Media Control. Drag and drop play onto the OnVoiceRecognition_Complete tab. Connect it to Switch and manually type in the condition hi.

2. Go to Play's Properties toolbox and set the following parameters:

Parameter Type Value
ConnectionId variable g_connectionId
Prompt1 string Hey there, Tex!
UserData string exit_app

Add Play#

1. Now we want to add the second Play action. Go to the Toolbox and expand Media Control. Drag and drop play onto the OnVoiceRecognition_Complete tab. Connect it to Switch and manually type in the condition how are you.

2. Go to Play's Properties toolbox and set the following parameters:

Parameter Type Value
ConnectionId variable g_connectionId
Prompt1 string I'm dandy, how are you?
UserData string exit_app

Add Play#

1. Now we want to add the third Play action. Go to the Toolbox and expand Media Control. Drag and drop play onto the OnVoiceRecognition_Complete tab. Connect it to Switch and manually type in the condition bye.

2. Go to Play's Properties toolbox and set the following parameters:

Parameter Type Value
ConnectionId variable g_connectionId
Prompt1 string See ya, don't let spleeny the evil spleen get you on the way out.
UserData string exit_app

Add EndFunction#

1. Since adding Plays will cause OnPlay_Complete or OnPlay_Failed to fire, we don't want to end the script yet. So go to the Toolbox and expand Application Components. Drag and drop an EndFunction onto the canvas. Connect it to each of the three Play actions.

Handle OnVoiceRecognition_Failed#

Add Hangup#

1. Now we are going to handle OnVoiceRecognition_Failed, so click on the event tab at the top of the canvas. Since we cannot proceed with the rest of the application if this voice recognition failed, the best course of action would be to hang up and end the script. So go to the Toolbox and expand Call Control. Drag and drop Hangup onto the OnVoiceRecognition_Failed canvas.

2. Go to the Properties toolbox of Hangup and set the parameter callId to the type variable and the value g_callId.

Add EndScript#

1. Go to the Toolbox and expand Application Components. Drag and drop EndScript onto the OnVoiceRecognition_Failed canvas and connect it to Hangup.

Create Grammer File#

1. The grammer file will be passed in to the VoiceRecognition action to identify what the user says into the phone. Open a text editor and copy and save the text below as jeeves.grxml.

<?xml version="1.0"?>
<grammar xml:lang="en-us" version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="JEEVES">

<meta name="maxspeechtimeout" content="4000"/> <meta name="incompletetimeout" content="2000"/>

<rule id="JEEVES" scope="public"> <one-of> <item> <ruleref uri='#utterance' /> hi <tag>SWI_meaning='hi';</tag></item> <item> <ruleref uri='#utterance' /> how are you <tag>SWI_meaning='how are you';</tag></item> <item> <ruleref uri='#utterance' /> bye <tag>SWI_meaning='bye';</tag></item> </one-of> </rule>

<rule id="utterance"> <one-of> <item repeat="0-3">uh</item> <item repeat="0-3">um</item> <item repeat="0-3">hum</item> <item repeat="0-3">eh</item> </one-of> </rule>

</grammar>}}}

Add jeeves.grxml#

1. In the Explorer window, R-click on the project JeevesTheVoiceRecRobot_CUAD and select Add Resources -> Add VoiceRecognition Resources.

2. Browse to the jeeves.grxml. Click open. Choose the Locale of Voice Rec File English(United States)and select Ok.

Build and Deploy Application#

1. In the Designer, Goto Tools-> Options...

2. Select Connectivity from the menu on the left. Check that the Framework Directory and Version is correct, and set the IP address for your server with the matching username and password. Click Ok.

Build Project#

Goto Build-> Build Project to build the project. You will see the following output in the Remote Console:

    ---- Build Started ----

    Building ...
    Preparing to build 'script1' ...
    Building 'script1' ...
    Build succeeded for 'script1'
    Packaging ... 
    Assembling ...

    Build successful

Install Project#

Goto Build-> Deploy to build the project. You will see the following output in the Remote Console:

Running the Application#

1. Login into the CUAE Admin console. Verify that the application is listed as Enabled Running.

2. Goto Applications-> List Triggers. Click on the application JeevesTheVoiceRecRobot_CUAD. To add a trigger, enter the trigger name in the text box and trigger value in the second text box. Here we are using "to" and "######". Click Add Parameter and then Done.

Tip: If this is the only application on your CUAE triggered on an incoming call, then you do not have to set a specific trigger. Your route pattern will automatically trigger the application.

Add Speech Recognition Server to CUAE#

1. Login to the CUAE Admin console. Go to Connections > List Connections.

2. Select Add. Specify the type Nuance and click Next.

3. Enter the value for the Host and Port. Select Save.

Add Speech Recognition License Servers to CUAE#

1. Login to the CUAE Admin console. Go to Connections > List Connections.

2. Select Add. Specify the type Nuance License Server and click Next.

Triggering the Application#

1. Call the specified trigger. A prompt "Please say hi,how are you or bye and wait for response" will be played for you.

  • If you say "Hi." you will get the response "Hey there, tex".
  • If you say "How are you?" you will get the response "I'm dandy, how are you?".
  • If you say "Bye" you will get the response "See ya, don't let spleeny the evil spleen get you on the way out".

The application will then terminate.

0 Attachments
292 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments
No comments yet. Be the first.