Hello World Sample
Contents
Here is a simple voice application to help you get started with Composer. This application says Hello World when the call is answered.
Simple Text-to-Speech Application
To build a simple text-to-speech (TTS) application that says Hello World to the caller:
- Create a new Composer Project called Hello World.
- Add the following blocks from the Basic Blocks Palette to the canvas area: Entry, Prompt, and Exit, then connect them with Output Links.
- Select the Entry block, or right-click the Entry block and select Show Properties View from the shortcut menu, if you want to set any properties (optional).
- Select the Prompt block, or right-click the Prompt block and select Show Properties View from the shortcut menu.
- Select the Name property and type a name in the Value field.
- Select the Prompts property and click the button.
- Click the Add button and type a name in the Name field (optional).
- Select Value in the Type drop-down list (default).
- Select Text in the Interpret-As drop-down list (default).
- Type HelloWorld (one word) in the Value field.
- Click OK.
- Save the file by selecting File > Save. You will not be able to generate code if you do not save the file.
- Generate the code by selecting Diagram > Generate Code, or by clicking the Generate Code icon on the upper-right of the Composer main window when the callflow canvas is selected.
- If you get any errors, double-click on the error to get the details and fix the problem. For the Hello World application, typical problems would be forgetting to add the Hello World prompt or forgetting to link the blocks together.
- If code generation succeeds, click OK at the confirmation dialog box.
- Make sure the project is deployed for testing. Composer bundles Tomcat 6.0 for running test applications. If you configured the Tomcat settings prior to creating your Composer Project, it will be auto-deployed on the Tomcat Server. You can double check this by clicking on the name of the project in the Project Explorer, then right-click and select Project Properties. Select the Tomcat deployment category and verify that the project is deployed. If not, click Deploy.
- Select the callflow in the Project callflows folder.
- Run the application by selecting Run > Run As > Run Callflow, or by right-clicking on the callflow file name in the Project Explorer and selecting Run As > Run Callflow.
The code is generated in the src-gen folder and the GVP debugger sends the call to your SIP Phone.
- Accept the call and you will be connected to the application on GVP. The call traces will become visible in the Call Trace view, and you should hear Hello World played through the phone.
Adding Blocks
There are a few ways to add blocks from the Palette to the canvas. The most common methods are as follows:
- Click on the block icon on the palette, release the mouse and click on the target location on the canvas area.
- Double-click a block icon on the palette.
- Click on the block icon on the palette, and while holding down the mouse button, drag and drop the block to the canvas.
Any of these methods will add the new block and you can then type the name of the block on the canvas itself. Click Property here to read about block naming restrictions.
Connecting Blocks
Blocks are connected to each other using connection links. There are two types of connection links:
- Output Links used to connect one block's output port to another block's input port, and
- Exception Links used to indicate error or exception conditions by connecting from a block's exception port to another block's input port.
To add a new Output Link (or Exception Link):
- Click the Output Link (or Exception Link) icon in the palette.
- Move the mouse over to the source block. The cursor will change to an upward arrow.
- Click once on the source block and keep the mouse button pressed. Then drag the mouse onto the target block and release the mouse button.
This will add the connection link between the two blocks. To use an Exception Link, the source block must have an exception port defined. This is done by selecting at least one supported exception within the block's Exceptions property.
Another method for adding an Output Link or Exception Link between two blocks is as follows:
- Click once on the source block to select it.
- Hold the Ctrl key and click once on the target block to select it as well.
- Double-click the Output Link (or Exception Link) icon in the palette to create a connection between the two blocks.
Again, to use an Exception Link, the source block must have an exception port defined.
The preference Show Connection Ports (in Composer Diagram Preferences) affects how connection links can be drawn to connect blocks. If it is switched on, links may be drawn directly by dragging from an outport of a block and dropped onto a block or its inport. This method will work in addition to using the Output link and Exception link tools. If the setting is switched off, connection ports are not displayed and therefore the method of drawing links mentioned above is not available.