Pages Menu
TwitterRssFacebook

Posted by on Jan 22, 2013 in Skype for Business® (Lync®)

Learning to dive: UCMA Coding

Learning to dive: UCMA Coding

Introduction

As you know, there’s another section of this blog devoted to scuba diving. Learning to scuba dive takes a bit of time, and requires some effort from the student. Firstly, there’s paperwork, quite a lot of paperwork. Then there’s dive theory: not too much, but just enough to ensure the basics are understood. There’s a handbook full of useful information and a DVD. A series of mini-tests confirms your understanding and a final exam ensures it. Then there’s pool sessions. There’s a lot to take in: the kit, putting it all together, getting in, swimming around, performing particular skills. Finally, a series of dives outside in “the real world” brings everything together and you’re ready to go diving for real.

Luckily your instructor is on hand to help you through all these stages. Imagine how complicated things might be if you didn’t have someone with you who’d done it all before, who could explain why things are the way they are, and provide tips and tricks. Even with an instructor, many people hit a wall partway through their training – “I can’t do this anymore”, “It’s not worth the stress”, “Maybe I’ll just take up rock climbing”.

Everyone agrees though, when the teaching is done, the course completed, the qualification obtained, the holiday booked and you jump into the gin-clear waters of Egypt: it’s all been worth it. Suddenly, everything comes together and you start reaping the benefit of all that hard work.

underwater

Coding in UCMA always seems to me a bit like learning to dive. There’s a lot of steps to be completed, quite a lot of work that needs to be put in. However what can be achieved is pretty cool and very powerful.

UCMA Coding

What it is

LyncThe Unified Communications Managed API (UCMA) is a Microsoft API available to Lync developers. As opposed to, say, the Lync Client SDK, this allows you to write programs which are usually wrapped into Windows services, which can interact directly with the Lync Server.

What it can do

A common use for UCMA is to write programs which run as autonomous agents on the Microsoft Lync architecture: bots. Bots can have their own identity and so can be added to contact lists just like users. Behind the bot you can write whatever you want. An example might be a weather bot which tells you the weather forecast each time you talk to it. More sophisticated examples include applications like TrainMe, which delivers video-based content based on training you’ve already received.

Using the UCMA framework you can keep track of conversations and instant message texts. UCMA application have some special powers in the Lync system, which means they can join conference sessions unseen and record everything that goes on, for instance. I haven’t tried it yet, but a UCMA implementation of the Turing test would be a fun project.

A UCMA-based bot can also open a Conversation Window Extension (CWE) when in a conversation with a user. A CWE is a pop-out webpage which the Lync client will display. Behind the scenes the bot can interact with the page, send it content and receive information about what’s happening on it. It’s like a sharing surface for both the user and bot. In this picture, TrainMe has opened a CWE in order to show training content:

TrainMeDashboard

What you need

In order to write UCMA code you need a Lync Application Server. This will only run within a Lync environment, which in turn will only run within an AD environment.

If you’re setting up a development environment, at a minimum you will need 3 servers: a domain controller, a Lync server and an Application server. In order to interact with your bot when it’s running you’ll also need client machines, running the Lync client application.

Unless you have an entire Lync infrastructure running on your development machine, or Visual Studio running on your Lync application server (both somewhat unlikely) you’ll also soon discover that a lot of the debugging tools you’re used to can’t be used: as nothing will work unless you run the code on a properly provisioned Lync application server.

Why it’s hard

UCMA development isn’t totally straightforward. For a start, there’s quite a lot of infrastructure requirements up front. Then, you need to provision a Lync Application Server, and ensure it is trusted within the Lync environment. Then you’ll need to create a Trusted Application Pool, configure replication from the central management store, define a trusted application, then one or more endpoints (using Power Shell). That’s before you start writing code!

I’ve glossed over these tasks, as well as some of the hardware requirements. The truth is, I don’t fully understand them! They aren’t my area of expertise, and this is one of the reasons UCMA development has a steep learning curve: by the time you get to actually writing code you’ve had to learn so much new stuff you probably don’t have any time left. I’m fortunate in that I have excellent colleagues who have been here before and help with the set up costs. If you want more information about Lync infrastructure, I’d recommend Tom and Justin‘s blogs, as well as CodeLync for more information on Lync development.

“it’s actually great fun writing UCMA applications and the actual API is really good. I just want you to understand the set-up costs.”

When you do get to write the code there’s a much-better-than-it-used-to-be-but-still-not-entirely-straightforward set of steps you need to go through in order to link your application to the endpoint you created so that you will receive notification of any new conversations and can generally do stuff. Due to the nature of the environments in which it is working, most of the API calls are asynchronous so you have to be diligent in your coding to avoid spaghetti code (especially when you consider that just start an instant messaging conversation with someone can involve more than 5 calls, which have to be chained together). I’m not trying to put you off: it’s actually great fun writing UCMA applications and the actual API is really good. I just want you to understand the set-up costs.

So, what now?

I’ve outlined some of the pain points with UCMA. I’ve hopefully also whetted your appetite for them. I think they are a valuable addition to any business setup involving Lync, as the interactions they allow with users are simple and effective.

If you’re interested in writing UCMA applications, I’d recommend this book: Professional Unified Communications Development with Microsoft Lync Server 2010 (Wrox Programmer to Programmer). It has good information about setting up application servers and configuring a test system as well as actual UCMA development. There’s also plenty of other material relating to Lync development using the other SDKs and APIs.

In my next blog post I’m going to be talking about how you can avoid all the pain of setting up, creating and maintaining UCMA applications and instead just enjoy the glory of your business processes being invigorated with Lync!

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

1 Comment

  1. Hi. I need to develop lync bot using UCMA 4.0. Do I need to create user endpoint for the same or application end point is needed.Also, should I use separate computer for development and lync server 2013. Please let me know the same as I am new to this.

Trackbacks/Pingbacks

  1. Learning to dive: UCMA Coding thoughtstuff | Tom Morgan | Lync News - [...] | Tom Morgan http://thoughtstuff.co.uk/2013/01/learning-to-dive-ucma-coding/ [...]
  2. Introducing LyncMe from Modality Systems | thoughtstuff | thoughtstuff | Tom Morgan - [...] can be used to automate business processes and enhance the Microsoft Lync experience. However, as I recently blogged, they…
  3. Developing Lync: Introducing LyncMe « Lync News - [...] can be used to automate business processes and enhance the Microsoft Lync experience. However, as I recently blogged, they…
  4. What is Lync? A non-technical introduction. | thoughtstuff | Tom Morgan - [...] I’ve already written about UCMA applications before, so if you’re interested, see my previous blog post about writing UCMA…

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.