Off late, I have been working on the Lync 2010 client SDK to understand how I can automate some tasks such as updating my Lync status or auto-answer Lync calls or IM conversations when I am away from my computer or in a meeting, etc. This is just the beginning of the list. There are several other tasks I have automated and I will eventually post here.
Here is the link to download Lync 2010 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=18898
Also, make a note of the requirements to install Lync SDK:
- Visual Studio 2008 SP1 or Visual Studio 2010 RTM for Microsoft Windows Forms or WPF development.
- Visual Studio 2010 RTM for Silverlight development.
- Microsoft .NET Framework 3.5 or later service pack.
- Microsoft Silverlight 4.0 runtime, installed with Lync 2010.
- Microsoft Silverlight 4 Tools for Visual Studio 2010.
If you don’t want to install Lync 2010 SDK (it comes with a lot of unnecessary baggage), you can just copy the model DLL at “C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Model.Dll” from a machine that has Lync SDK installed. This should be sufficient for the task outlined in this post.
For now, I will start with a basic overview of the Lync scripting model and then show a simple example of changing the Lync client status using PowerShell.
There are two Lync development models as described in Lync 2010 SDK documentation:
- Lync 2010 Controls provides features such as search, presence, instant messaging (IM) calls, and voice calls, which can be integrated into custom applications.
- Lync 2010 API provides the programming interfaces to develop Lync 2010 applications.
In the context of this post and all other future posts in this topic, I shall talk only about the Lync 2010 API and not the controls.
In the context of Lync 2010 API, there are two development scenarios:
- Lync 2010 Model API can be used to replicate Microsoft Lync 2010 features in an application while suppressing the Lync 2010 user interface.
- Lync 2010 Extensibility API can be extend an existing application by integrating a new Microsoft Lync 2010 conversation window in the application.
In the Lync 2010 model API — in UI suppression mode — several Lync 2010 features are not available. This is where the extensiblity API can be used effectively.
So, that is a 30000 ft. overview of Lync 2010 SDK. Let us see example on using Lync 2010 API to change the status of the Lync 2010 client.
#We just need the Model API for this example
import-module "C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Model.Dll"
#Get a reference to the Client object
$client = [Microsoft.Lync.Model.LyncClient]::GetClient()
#Set the client to reference to the local client
$self = $client.Self
#Set the availability to away
$availability = 15500
#Get the contact info
$contactInfo = new-object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
#Set the personal note as status message
"I have no access to IM/E-mail off hours. Feel free to call me or text me, in case you need immediate response")
#Set the availability
#Set the activitty to off-work
#Publish the activity and availability status
$ar = $self.BeginPublishContactInformation($contactInfo, $null, $null)
The above example is self-explanatory. The first step loads the model API and the subsequent steps load the client object and perform status updates. Stay tuned for more.