HttpMakeCall-Designer - Wiki
Wiki
HttpMakeCall-Designer
Creating A New Project#
To create a project:
- Launch the Cisco Unified Application Designer
- Select the File -> New Project option and enter the Project Name and Location in the "New Application Designer Project" form
Figure 1. Adding a Project
Name the New Application Script and Select a Trigger Event#
- The next stage in the creation of a project is to define the application script trigger. In the case of the HttpMakeCall application the script will be triggered by the Metreos.Providers.HttpGotRequest event.
Figure 2. Add An Application Script and Trigger Event
- The CUAD canvas now contains both the script and OnGotRequest tabs.
Figure 3. New Project With Trigger Event
Process The HttpGotRequest Event#
- Add the local variable "remoteHost" to the "OnGotRequest" phase, by right clicking on the "variable tray" at the bottom of the canvas and selecting "Add Item"
Figure 4. Add A Local Variable
- Inititialize the "remoteHost" with the "RemoteHost" value that is passed into the "OnGotRequest" event, by selecting the value "RemoteHost" in the list box for the "InitializeWith" property.
Figure 5. Initialize A Local Variable Property
- To process the inbound HttpGotRequest event, select R-click on the left pane "CUAD Toolbox" MakeCall action in the "Call Control" list of available action; and drag the action onto the designer canvas. After this step 2 new tabs will be displayed in the project: OnMakeCall_Complete and OnMakeCall_Failed. The new actions are listed in the CUAD Explorer view as well.
- Draw a branch condition connector from the output end of the "Start" node to the input end of the MakeCall action.
Figure 6. Branch Condition To The MakeCall Action
- Add The Global Variable g_CallID
- To add the global variable g_CallID, select the "script1" tab, R-click on the Variables fodler on the canvas and enter the name of the variable to add.
Figure 7. Create A Global Variable
- Add another Global Variable g_To in similar way.
- Add an Installer object to the application thru which one could fetch data passed from the CUAE admin console application configuration form during the application run-time.
- Select "File -> Add Installer -> New Installer" from the top CUAE menu (select Yes if you are prompted to save changes)
Figure 8. Add An Installer Object
Set the Installer config line item values:
- Name = "To"
- Display Name = "To"
- Description = "Number To Call"
- Required = "Checked
Figure 9. Add An Installer Configuration Item
- Dbl click on the script1 tag in the explorer window to (select Yes to save the changes) and continue editing the application script.
- Initialize the global variable "g_To" with an Installer object config value (which would be passed to the application at run-time) by selecting the global variable and setting the basic property for InitializeWith to "Config.To" from the selection list
Figure 10. Configure A Global Variable
Set the "MakeCall" action parameters:
- Select the MakeCall node on the canvas to display the action's properties
- Under action parameters, set the "To" = global variable "g_To" by expanding the "To" parameter and then selecting a "User Type" of var. Then select global variable G "g_To" from the list of variables available to the "To" action parameter.
The MakeCall action returns the CallID value. Save this value to the global variable "g_CallID" by setting the Result Data "CallID" value to the global variable G "g_CallID"
Figure 11. Make Call Action Parameters
To process the "Default" return value state after the MakeCall action, select the "SendResponse" action in the "HTTP" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the MakeCall action to the SendResponse action.
Figure 12. Branch Condition To The SendResponse Action
In order to process the state of the return value as "Success" for the MakeCall action, select the "SendResponse" action in the "HTTP" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the MakeCall action to the SendResponse action and designate the state as a "Success" by clicking on the text "default" and choosing the string "Success" from the drop down.
Figure 13. Branch Condition To The SendResponse Action
Formatting the string to be send via the SendResponse action to the browser for the "Default" (Non-Success) state:
- Select the action node on the canvas to display the action's properties
- Enter a string for the message body ie. "Failure"
- Set the Content-type =text/plain
- Set the RemoteHost = local variable "remoteHost" by expanding the RemoteHost property and then selecting a "User Type" of var. Then select local variable L "remoteHost" from the list of variables available to the RemoteHost action property.
- Set ResponseCode = 200
Figure 14. SendResponse Action Properties - Default
Formatting the string to be send via the SendResponse action to the browser for the "Success" state:
- select the action node on the canvas to display the action's properties
- Enter a string for the message body ie. "Success"
- Set the Content-type =text/plain
- Set the RemoteHost = the locale varaiable "remoteHost" by expanding the RemoteHost property set and then selecting a "User Type" of var. Then select local variable L "remoteHost" from the list of variables available to the RemoteHost action property.
- Set ResponseCode = 200
Figure 15. SendResponse Action Properties - Success
To complete the state of the return value as "Default" and to exit the script execution for the MakeCall action, select the "EndScript" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "SendResponse" action to the "EndScript" action.
To complete the state of the return value as "Success" and to exit the function, select the "EndScript" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "SendResponse" action to the "EndFunction" action.
Figure 16. EndScript and EndFunction for OnGotRequest
Process The Make Call Event#
To process the OnMakeCallComplete function of the MakeCall event, select the "Play" action in the "Media Control" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
Figure 17. Media Control Play Action
- Add the local variable "connectionID" to the "MakeCall" phase, by R-clicking on the "variable tray" at the bottom of the canvas and selecting "Add Item"
- Inititialize the "connectionID" with the "ConnectionID" value that is passed into the "MakeCall" event, by selecting the value "ConnectionID" in the list box for the "InitializeWith" property.
Figure 18. Add A Local Variable - connectionID
- In the play action you can direct the Media Engine to play a .wav file.
- Create a sub-directory say 'media' in the application's project directory ie. "C:\temp\HttpMakeCall\media", and place your .wav file there. Consider this application will play the "makecall_good_bye.wav" file.
- To associate the .wav file to the application so that it can be accessed by the "Play" action:
1. Select "File -> Add Resource -> Add Media -> Audio File" from the Top menu in the CUAD.
2. Browse to the location of the media fle and select the file.
Note: The CUAD and CUAS supports localization. When adding the audio file you have the option to select the "locale" of the media file(s)
Set the "Play" action parameters:
- Select the Play node on the canvas to display the action's properties
- Set the ConnectionId = local varaiable "connectionId" by expanding the ConnectionId property and then selecting a "User Type" of var. Then select local variable L "connectionId" from the list of variables available to the ConnectionId action parameter.
- To attach the media file to the Play action as the first prompt; the user will hear this upon answering the phone; set Prompt1 = makecall_good_bye.wav
Note: In the CUAD explorer pane, under the Media resource directory tree, you will see that the media file resides in the "en-us" locale. "Which depends on your wav locale information"
Figure 20. Attach A Media Resource To The Play Action
To complete the state of the return value from the Play action as "Default" (fail), select the "Hangup" action in the "Call Control" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Play" action to the "Hangup" action.
- Set the "Hangup" action parameter CallId to global variable "g_CallID" by selecting G g_CallID in the "CallId" list.
Figure 21. Hangup Action Caller ID
To complete the state of the return value as "Success" for the "Play" action and to end the function. Select the "EndFunction" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Play" action to the "EndFunction" action.
To complet processing the state of the return value as "Default" for the "Play" action and to end the script. Select the "EndScript" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Play" action to the "EndScript" action.
Figure 22.Finalize OnMakeCallComplete
Finalize the "OnMakeCall_Failed" function for the MakeCall action by adding an "EndScript" action to the function and connecting the start with a branch condition connector to the "EndScript" action.
Figure 23. Finalize OnMakeCall_Failed
On Play Complete#
To ensure a graceful end to the "OnPlay_Complete" function, add a "Switch" block to test for the termination status.
- Add the local variable "terminationCondition" and initialize it with the run-time value for "TerminationCondition"
- Select the "Switch" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Intialize "SwitchOn" parameter value of Switch action item with terminationCondition.
- Draw a branch condition connector from the "Start" action to the "Switch" action.
Figure 24. Play Complete Termination State
To process an event where the play action is not successful (default), select the "Hangup" action in the "Media Control" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Switch" action to the "Hangup" action.
- Initialize the "Hangup" action parameter "CallID" with the global variable "g_CallID"
- Select the "EndScript" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Hangup" action to the "EndScript" action.
To process an event where the play action is successful, select the "EndScript" action in the "Application Components" list of available actions in the left pane "CUAD Toolbox", and drag the action onto the designer canvas.
- Draw a branch condition connector from the "Switch" action to the "EndScript" action and change the label on the connector from "Default" to "AutoStop". Note that the term "AutoStop" is not a term supplied on the drop-down list, but must be typed in manually.
Figure 25. Finalize OnPlay_Complete.
Finalize the "OnPlay_Failed" function for the Play action by adding an "EndScript" action to the function and connecting the start with a branch condition connector to the "EndScript" action.
Figure 26. Finalize OnPlay_Failed.
Processing Call Control Event Triggers#
During the execution of the test application the script has the ability to process known provider event triggers. In the case of this application, the event trigger that we need to process is RemoteHangup.
- To add the event to the script:
- Select the script1 tab
- Drag the "RemoteHangup" event from the "Toolbox - Call Control" item list and under the "Events and Functions" folder on the canvas"
- Finalize the "OnRemoteHangup" function for the RemoteHangup event by adding an "EndScript" action to the function and connecting the start with a branch condition connector to the "EndScript" action.
Figure 27. Call Control Event Trigger - RemoteHangup.
Define The Application "OnGotRequest" Trigger#
Before the application can be deployed, set the "OnGotRequest" trigger event parameter "URL"
- Select the "OnGotRequest" trigger in the script1 tab
- set URL = /HttpMakeCall
Figure 28. Application "OnGotRequest" Trigger.
Application Build And Deployment#
Prior to building and deploying the application, configure the "Connectivity" options between the CUAD and the CUAS.
- Select "Tools -> Options -> Connectivity" from the top menu
- Enter the IP address and username / password for the CUAE server, then save the change.
Figure 29. Connectivity Options.
To both build and deploy the application, select "Build -> Deploy" from the top menu.
Note:
- The status of the build and deployment is displayed in the "Ouput" pane at the bottom of the CUAD.
- In the case that this is not you first deployment to the CUAE server you will be present with a pop-up prompt to select "Upgrade" or "Reinstall".
Figure 30. Application Build And Deployment.
To view the status of the application in the CUAE Admin console. Log into the CUAE management console and select applications from the menu list.
Figure 31. CUAE Admin Console Application Status.
To configure the application number to call when triggered:
- click on the applicaion in the application list
- enter the value for "To"
- apply the change
Note: You are also presented with additional run-time parameters in the application configuration form that you may update/change as well
Figure 32. CUAE Admin Console Application Configuration.
Launching The Application#
- To launch the application, open a browser and enter the URL http://<cuae_ip>:8000/HttpMakeCall
Figure 33. Launch The Application