Blog

Custom development in Lync 2013

Most people think of Lync as an instant messages communicator that allows you to make some calls. But today, Lync is so much more. Off course you can send IM, do group chats or make (video) calls, but now you can also connect the Lync Server to your phone line and infrastructure and then it becomes a super-efficient communication and collaboration platform. I know what I'm talking about, because we use it in Orbit One every day. 
 

 

Orbit One is Microsoft vTSP partner and we are quite experienced in Lync for a few years now. We do both ITPro stuff like setting up Lync servers but we also do Lync custom development. Yes, development! Microsoft has introduced several SDK's that allows us to extend and customize Lync on different levels. This year (July 2013) Microsoft has released a new version of tools, APIs, SDKs and all extra requirements. This is something huge, and let me introduce it to you so to save you some time in your research.

 

SDK overview

You can extend and customize a Lync client or change its behavior on a server and infrastructure level. Depending on what your goal is, you will pick the right SDK. In this post I will be focusing on Lync 2013 SDK which is all about extending the functionality of Windows Lync clients.

 

Links

Lync 2013 SDK

The installation package is 56 MB and it takes few moment to install. Of course you will need the Lync client application. You can download a Lync client from Microsoft Download Center: Lync client 32bit or Lync client 64bit version.

I also really recommend you to walk through training labs and videos. It helps a lot. Here you can find a Visual Studio 2012 solution that you can use to play with.

 

Basics

You must know that we will be attaching our code to an existing Lync client that must be running on your machine. We are not building a separate Lync client (of course it possible, but it's more complicated). So basically we will be listening to different events and react to them.

 

Platform

So, start Visual Studio 2012 and create a new project. First question: What project type should I choose? Well this is your choice. If you want to monitor some activities, it can be a Console application, but if you would like to add some forms, dialogs or show additional data, then your choice should be WinForms or WPF or even Silverlight!

What's good about Lync 2013 SDK it is platform independent. It's just a set of classes, so you can use them in all .NET Framework in general.

But on the other hand, especially in WPF and Silverlight you will find special Lync controls that comes out-of-the box.

 

Demo 1: Hello world

I will show you how to build simple 5 minutes demo like "Hello world".

Start Visual Studio 2012 and create a new project.

Add Windows.Lync.Model.dll reference from SDK.

SDK is located in ..\Program Files (x86)\Microsoft Office\Office15\LyncSDK and all binaries can be found in \Assemblies\Desktop subfolder.

Next step is to create ConversationAdded event handler so you will know when someone is calling or sending an instant message. Use the GetClient method from the LyncClient class. Then navigate to the ConversationManager property to find ConversationAdded and ConversationRemoved events. 

 

public MainWindow()

{

    InitializeComponent();

 

var client = LyncClient.GetClient();

client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;

client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;

}

 

When someone will start a new conversation with you on Lync, this event will raise. The code below shows you how you can check who is calling or who is sending you the instant message:

 

void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)

{

var conversation = e.Conversation;

var details = "Hello Lync 2013 SDK!" + Environment.NewLine;

 

if (conversation != null)

{

if (conversation.Properties.ContainsKey(ConversationProperty.Inviter))

{

var contact = (Contact) conversation.Properties[ConversationProperty.Inviter];

if (contact != null)

{

details += "INVITE FROM: " + contact.Uri + Environment.NewLine;

}

}

}

Debug.WriteLine("Incomming conversation details: " + details);

}

 

The Conversation class is very interesting. You will find everything about all Participants - if it is a group chat, everybody is listed. You can read the conversation subject, state, etc. This is very rich and powerful.

Imagine that you can build your Lync assistant and show additional data about a caller from you customers database using his sip, email, name or other unique identifier.

 

 

In picture above you can see an original Toast notification when my colleague SÅ‚awek is calling me, and next to it, the blue WinForms (my custom, proof-of-concept extension) window that shows additional data that comes from our Microsoft CRM 2011. If the data is cached right, this window is visible right after the incoming call toast is showed.

Another example might be the ability to open an additional window where you can make notes about your call and that allows you to store them later in your database…

 

Demo 2: Real time translation

http://code.msdn.microsoft.com/lync/Lync-2013-Translate-a-a849e513

Here you can find a great example of a simple demo application that allows you to add translations to your conversations. Of course, keep in mind that this is just a proof of concept app. It uses Silverlight as UI and attaches itself to a new conversation (be sure to have at least one open conversation - with nobody in particular). When you start this demo you will be able to choose the source and target language. Then you can type, translate your message using the Bing translate service and send the translated message to the other participant. This is a great example that shows the wide variety of possibilities.

  

Build your own Lync client

The truth is, you can build your own Lync UI. You can disable the Lync Windows client from your code (from your extension) and turn it into the Suspended UI mode. From this moment on, the original Lync will be disabled and you will have think about everything like: how to show a toast notification on an incoming call, open a chat window, manage contacts and states, etc..

It's a lot of work, but this gives you unlimited power and control. 

Conclusion

After reading this post I hope you understand how easy it is to start your adventure with Lync 2013 development. With the new set of tools, APIs and SDKs its much more easier. I'm not saying it's perfect, but Microsoft made good step in right direction. This makes Lync a more cross browser, cross platform and cross operating system.

 

If you have any questions, suggestion or ideas, do not hesitate and contact us.

Technology Technology

Op 25/07/2013 door Wojciech Poniatowski

blog comments powered by Disqus