A UCMA 3.0 "Hello World" App.
Writing a “Hello World” app using UCMA is rather simple. There are few loopholes, but I will walk you through that.
Obviously the first thing we need to do is make sure you have your development environment setup properly. Minimally you will need either Vista, Windows 7 or Server 2008 64 bit operating system. Additionally you will need Visual Studio 2008 or 2010. I have not tried to use this on the free version of Visual Studio Express. You will also need to install the UCMA SDK. Finally you will need some sort of soft phone like x-lite.
For those of you who are using Speech Server 2007 and are wondering if you can have both UCMA and Speech Server 2007 installed on the same machine, it is possible. You just need to make sure Speech Server is not running when using a UCMA app and vice-versa.
For those who have UCMA 2.0 installed, you will need to uninstall it first before installing UCMA 3.0. I should also note that installing and uninstalling UCMA 2.0, then installing UCMA 3.0 did cause a problem with my Speech Server install, or at least I think it did. Ultimately I had to uninstall UCMA 3.0 then I had to uninstall .NET 4.0 framework (Speech Server will not reinstall with .NET 4.0), then I had to reinstall Speech Server, reinstall .NET 4.0 through the Visual Studio install and then reinstall UCMA 3.0. After all that, Speech Server 2007 functioned properly.
UCMA 3.0 installes quite a few components to include a speech and TTS engine, the Lync redistributables, the speech Workflow API and the other UCMA APIs
After installation of all the components you are ready to crank up Visual Studio. In Visual Studio:
1. Click File/New/Project.
2. Select .NET Framework 3.5 from the dropdown that lists the different versions of the frameworks installed. You must be in .NET 3.5 mode to see the Communications Workflow template.
3. In the Installed Templates expand out Visual C# (or if you prefer Visual Basic) and click on Communications Workflow.
4. For this app we will choose Inbound Sequential Workflow Console Application.
5. In the Name: field name the app UCMA Hello World.
6. Choose your solution location in the Location: field.
7. Click OK.
8. In the Select Language dialog box click OK. You should now be presented with what may look rather familiar to Speech Server developers.
In the toolbox you should now see the familiar Workflow activities as well as the UCMA Speech activities that were loaded when you installed the UCMA SDK.
1. Drag and drop a SpeechStatementActivity into the CommunicationsSequenceActivity just above the DisconnectCallActivity.
2. Right Click the speechStatementActivity1 activity and choose properties.
3. In the MainPrompt property, type Hello World.
At this point we have essentially completed the application and it will run. The only problem is we need to tell the code that we are not connecting to the default endpoint which is a Lync server. Instead we want it to use a standard SIP connection. To do that we need to make one little code change.
1. In Solution Explorer double-click to open the Promgram.cs file. It is this file that starts up the workflow runtime and in so doing starts up the CollaborationPlatform. The CollaborationPlatform is what handles the incoming calls.
2. If you scroll down to the Initialize() method you should find a line of code that looks like this:
_endpoint = new ApplicationEndpoint(_collabPlatform, settings);
3. Just above the line of code indicated in step 2 above, enter this code:
settings.IsDefaultRoutingEndpoint = true;
4. Now start the application in Debug mode.
5. After compiling and running you should see a console window that should displays the following:
Step 1 of 3: Initializing the Workflow Runtime... Complete.
Step 2 of 3: Starting CollaborationPlatform... Complete.
Step 3 of 3: Establishing Endpoint... Complete.
Press Enter to stop.
NOTE: If you do not see “Establishing Endpoints… Complete”, there is a problem and usually the problem is some other application is listening on port 5060 (the standard SIP port). For example Speech Server may still be running on your box. If so, shut down the process and try again.
At this point you are ready to dial into the app. Be sure your softphone is able to connect to a transport of TCP. x-lite is capable of doing this by specifying it in the SIP URI. For example if I use x-lite on my local box I need to use something like this:
sip:1234@localhost:5060;transport=tcp
As you can see, this is a very simple application. From here, however Speech Server developers can probably get going with some decent development. As you can see, the “server” for this application is a console application. Clearly, putting a console application into production is probably not a good idea. Here is Michael Dun’s solution from a UCMA 2.0 blog. I wrote my own Windows Service app that calls the necessary methods from the Program class that seems to work fine for now.
Later I will blog on some pitfalls you are likely to run across and some suggested solutions.