Lync Development

Adding Custom Commands to Lync Client Menus


We will discuss one of the ways in which the Lync client can be customized by offering contextual options that are specific to your own business needs which is creating custom menu items.

If you want to add your custom Lync application shortcut to the Lync Client you have to use the custom commands. The term “contextual conversations” comes up a lot in working with Lync. As Lync becomes more and more integrated into people’s workflows, it can automate much of this sending and retrieval of appropriate context, saving time and increasing productivity.

Use custom commands embedded in the Lync client UI to launch applications on the Microsoft Windows desktop. these custom commands are menu items added by the developer to the Lync client UI. You can add the custom commands to Lync client menus and pass the SIP Uniform Resource Identifier (URI) of the current user and selected contacts to the application that the custom command starts.

The custom commands that you add can appear on one or more of the following menus:

  • The Tools menu, on the menu bar in the Lync main window
  • The shortcut menu for contacts in the Contacts list
  • The More options menu, in the Conversation window
  • The shortcut menu for people listed in the Conversation window participant list
  • The options menu in a contact card

When you open Lync now, and right-click on a contact, menu items appears as follow:

Context Menu

You can define custom commands for two types of applications:

  • Apply only to the current user and are started on the local computer.
  • Involve additional users, such as an online collaboration program, and must be started on each user’s computer.

The custom command can be invoked in the following ways:

  • Select one or more users, and then choose the custom command.
  • Start a two-party or multiparty conversation, and then choose the custom command.

Adding Custom Command

To add a custom command for an application, add a registry subkey and the registry entries described in this topic.

Registry subkey is the application GUID, added at the following locations:

  • Lync Client 2013, 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps
  • Lync Client 2013, 64-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Lync\SessionManager\Apps
  • Lync Client 2010, 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator\SessionManager\Apps
  • Lync Client 2010, 64-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Communicator\SessionManager\Apps

Registry entries under each GUID subkey, add the entries described as follow

Entry Type Description
Name REG_SZ The name of the application as it appears in the Lync UI.
Path REG_SZ The full path of the application along with parameters, including the default parameters of %user-id% and %contact-id%. The parameters pass a string representing the SIP URI of the user signed in to Lync and the selected contact or contacts to the application launched.
ApplicationType DWORD 0 = Executable, 1 = Protocol.
ApplicationInstallPath REG_SZ The full path of the executable, which is required if ApplicationType is 0.
SessionType DWORD 0 = local session, 1 = two-party session, 2 = multi-party session.
ExtensibleMenu REG_SZ A semicolon-delimited list of places where the command appears. Possible values include MainWindowActions, MainWindowRightClick, ConversationWindowActions, ConversationWindowRightClick, and ContactCardMenu. If ExtensibleMenu is not defined, the default values of MainWindowRightClick and ConversationWindowActions are used.

Examples show usage for HTML and .exe paths:

c:\\ext_menu.exe /userId="%user-id%" /contactId="%contact-id%"
http://localhost/Code4Lync/Test.html?userId=%user-id%;contactId=%contact-id%

See Also the following Registry Editor (.reg) files as examples:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps\{3E0352E8-21F3-4E00-AA46-2ADA7085C9AD}]
"Name"="Code 4 Lync Custom Application"
"ApplicationType"=dword:00000000
"ApplicationInstallPath"="C:\\YourApp.exe"
"Path"="C:\\YourApp.exe /userId=%user-id% /contactId=%contact-id%"
"SessionType"=dword:00000000
"ExtensibleMenu"="ConversationWindowRightClick;ContactCardMenu;MainWindowRightClick"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps\{96DC330B-0A57-4A26-963B-75A109CD3C30}]
"Name"="Code 4 Lync Custom Application"
"Path"="C:\\Program Files (x86)\\YourApplication\\YourApp.exe %param1%"
"ToolTip"="tooltip text"
"ApplicationType"=dword:00000000
"SessionType"=dword:00000002
"Extensiblemenu"="MainWindowActions;MainWindowRightClick;ConversationWindowActions;ConversationWindowContextual;ConversationWindowRightClick;ConversationWindowButton"

Using Custom Command

The following table describes how to launch an application with a given ExtensibleMenu value.

ExtensibleMenu value Action
MainWindowActions In the upper-right corner of the Lync 2013 conversation window, click the Show menu button, point to Tools, and then click the custom command.
MainWindowRightClick In the conversation window, right-click a contact in the Contact List or Search Results pane, and then click the custom command.
ConversationWindowActions In the lower-right corner of the conversation window, click the More options ellipse, point to Actions, and then click the custom command.
ContactCardMenu Click the custom command on the contact card Options menu.

To test your custom menu by retrieve the %user-id% and %contact-id% arguments, add C# code to the application launched by the custom command.

static void Main(string[] args)
{
  if (null == args || args.Length == 0) Console.WriteLine("No args");
  else
  {
    foreach (string arg in args)
    {
      Console.WriteLine("Arg: " + arg);
    }
  }
  Console.ReadLine();
}

Removing Custom Command

Removing the GUID subkey removes the appropriate custom commands from the Lync UI.

Advertisements

Microsoft Lync 2013 SDK


Microsoft introduced the new Lync API release for Microsoft Lync 2013. Microsoft Lync 2013 SDK is the client-side API set that enables the integration and extension of Lync experiences.

With the Lync SDK, you can quickly add Lync 2013 features to an existing business application, extend the Lync client itself or, if you have the need, build a custom UI built atop the Lync client platform.

The Microsoft Lync 2013 SDK includes the Lync 2013 API, a managed-code (.NET) API that developers use to build applications that leverage the Microsoft Lync 2013 collaboration features. In addition to the Lync 2013 API, the Lync SDK includes a set of UI controls that can be used to add Lync features to a Microsoft Windows Presentation Foundation (WPF), or Microsoft Silverlight 4.0 application. The Lync 2013 SDK also ships with a set of working code samples and documentation to help you become a productive Lync developer as quickly as possible.

It is important to note the Lync SDK’s development model does require the Lync client to be installed on the user’s machine and the API is called from outside the Lync process, manipulating the same object model on which the Lync client is built.

Microsoft Lync Server 2013 SDK

The Microsoft Lync Server 2013 SDK includes the Microsoft Lync Server 2013 SIP Application API documentation, library (ServerAgent.DLL), application development tools, and sample applications.

The Lync Server 2013 SDK includes three Lync Server 2013 SIP Application API references that can be used to create Session Initiation Protocol (SIP) server applications that customize and extend the functionality of Microsoft Lync Server 2013:

  • SIP application manifest
  • Microsoft SIP Processing Language (MSPL)
  • Microsoft.Rtc.Sip namespace

This SDK is Intended for the Following Audiences

  • Developers who want to use application manifests and MSPL scripts to implement simple custom SIP message filtering and routing on computers in a Lync Server 2013 deployment.
  • Experienced SIP developers who want to create SIP-based managed code server applications that implement real-time content delivery or instant messaging infrastructure. This includes applications that work directly with SIP transaction objects or support multithreaded transactions.

What’s New

More than 70 new topics have been added to the SDK. These topics explain new features of Lync SDK as well as giving you a more in-depth look at features introduced in a previous release of the SDK.

New SDK Features

Lync SDK give you three new features will let you provide your custom application users with a complete collaboration experience. The three areas that we have enhanced the Lync SDK include:

  • Resource sharing. This feature allows a client to share a running process, desktop, or any one of the displays attached to a computer.
  • Persistent chat support. You can build a persistent chat client as well as a persistent chat add-in application that is attached to a persistent chat room.
  • On Line meeting content management. You can manage the contents of an on line meeting content bin, meeting content sharing stage, and meeting video display sources.

Most Solved Issues

Microsoft solved the problem of viewing the video in the UI Suppression Mode with the Lync 2013 SDK (preview) and now it is working fine but you need to install the latest release of the Microsoft Lync client (15.0.4454.1506) version

Related Information

Lync 2013 SDK training videos for developers
Lync 2013 Developer documentation
Download Microsoft Lync 2013 SDK

Understanding Lync in UI Suppression Mode and Set the Registry


Start developing apps that uses Lync SDK in UI Suppression mode, you must understanding the tradeoffs that you’re making is important; i.e. you are responsible for creating custom versions of almost the entire Lync client user interface. Additionally, your application has to programmatically sign the user into the Lync client using a custom login interface that you are also responsible for creating.

All the user interface elements of the Lync client are not visible when it is running in UI Suppression mode except the VideoWindow control that is used to render video. The VideoWindow control is only available when running in UI Suppression mode. Later in this chapter, you learn how to access the VideoWindow when working with conversations that use the AudioVideo modality.

The Lync controls are not available when the Lync client is running in UI Suppression mode; they are automatically grayed out and disabled. You must create your own custom versions of controls.

Automation is also unavailable when running in UI Suppression mode. Automation provides an easy way to start conversations in all modalities; however, it relies on Lync user interface elements such as the conversationwindow.

Configuring Lync UI Suppression

Lync UI Suppression mode is configured in the registry. When the Lync client is put into UI Suppression mode. To put Lync into UI Suppression mode, you must create and set a registry key called UISuppressionMode in the appropriate location in the Windows registry depending on whether you’re running the 32 – bit or 64 – bit version of the Lync client.

After Setting the Registry to run the Lync client in UI Suppression Mode the client is disappeared and doesn’t opened unless you update the registry again to run outside of UI Suppression Mode

Enable UI Suppression mode in the Lync Client 32-bit Version

Create a key in the registry and name it UISuppressionMode and set its value to 1 in the following location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator]
"UISuppressionMode"=dword:00000001

Enable the UI Suppression mode in the Lync Client 64-bit Version

Create a key in the registry and name it UISuppressionMode and set its value to 1 in the following location: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Communicator

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Communicator]
"UISuppressionMode"=dword:00000001

Disable the UI Suppression mode in the Lync Client 32-bit

Set the UISuppressionMode registry key value back to 0

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator]
"UISuppressionMode"=dword:00000000

Disable the UI Suppression mode in the Lync Client 64-bit

Set the UISuppressionMode registry key value back to 0

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Communicator]
"UISuppressionMode"=dword:00000000

(Source: Professional Unified Communications Development with Microsoft Lync Server 2010 by George Durzi and Michael Greenlee)

Join Lync Conference Using Lync 2013 SDK


This article explains how to prepare for and join online meetings using Microsoft Lync 2013 SDK, you can join a scheduled online meeting with colleagues and clients from down the hall or across the world without leaving your desk.

For online meetings with audio or video calls You can access your scheduled conference invite using Microsoft Lync 2013 SDK.

When a user schedules an Online meeting in Outlook 2007/2010 the meeting and Lync information associated with that meeting are stored in a number of MAPI properties on the Appointment Item.

You can use these information further to do many tasks i.e. to join a conference meeting, also you could use these information to put it in a calendar.

The following demonstrations run on different computers. These computers is used to start a conference by using Microsoft Lync 2013 SDK UI Automation mode or Microsoft Lync 2013 SDK UI Suppression mode.

Getting the Online Meeting URL

You could get the online meeting URLs by the Managed EWS API, Microsoft encourage Microsoft .NET Framework developers to use the EWS Managed API instead of auto-generated proxies to develop against Exchange Web Services. The EWS Managed API object model is significantly easier to use than auto-generated proxy object models.

You get more information how to use EWS in the previous post Get Lync Online Meetings’ Information using the EWS Managed API

Getting the Conference URI

The conversation properties that you use to form a complete conference URI are null at the time that the conversation is created.

To get the conference URI properties, you register for the Conversation.PropertyChanged event on the conversation to get the URI value

The following are examples of how to build a conference join URL using properties of the conversation.

UI Automation Mode

private void Conversation_PropertyChanged
    (object sender, ConversationPropertyChangedEventArgs e)
{
    //Getting meeting url
    if (e.Property == ConversationProperty.ConferencingUri)
    { 
        string ConferenceUri = "conf:" 
           + ((Conversation)sender).Properties[ConversationProperty.ConferencingUri]
           + "?" + ((Conversation)sender).Properties[ConversationProperty.Id];
    }
}

UI Suppression Mode

void ConversationManager_ConversationAdded
    (object sender, ConversationManagerEventArgs e)
{
    //Getting meeting url
    string url = string.Empty;
    string domain = string.Empty;
    string name = string.Empty;
    string id = string.Empty;

    url = ConferenceUrl.Replace("https://meet.","");
    url = url.Substring(0, url.Length);
    domain = url.Substring(0, url.IndexOf("/"));
    url = url.Replace(domain + "/", "");
    name = url.Substring(0, url.IndexOf("/"));
    id = url.Replace(name + "/", "");
    url = "conf:sip:" + name + "@" + domain + 
          ";gruu;opaque=app:conf:focus:id:" + id + "?" +
          _activeConversation.Properties[ConversationProperty.Id].ToString();
}

Joining the Conference

Once the conference URI is obtained by another user, use the BeginStartConversation method to join a conference in a Microsoft Lync 2010 SDK application. The string argument of the call is the conference URI.

UI Automation Mode

IAsyncResult ar = LyncClient.GetAutomation().BeginStartConversation(
    this.ConferenceUriObtainedFromEmail_string,
    this.Handle.ToInt32(),
    null,
    null);
_Automation.EndStartConversation(ar);

UI Suppression Mode

void ConversationManager_ConversationAdded
    (object sender, ConversationManagerEventArgs e)
{
    //Join the conference
    _activeConversation.ConversationManager.JoinConference(url);
}

Building Communications Applications With The Lync SDKs


The Lync 2010 SDK includes the Lync controls, a set of Silverlight and Windows Presentation Foundation (WPF) controls that you can use to integrate functionality found in the Lync client directly into your applications.

The SDK also includes the Lync application programming interface (API), a brand – new, managed API for building custom communications solutions. The Lync API is intended to replace the IMessenger and UCC APIs available with Office Communications Server 2007 R2. The IMessenger API was easy to get started with, but was fairly limited in functionality; it was also a little cumbersome to troubleshoot because it used COM interoperability to interact with the running instance of Communicator on the user’s machine.

The UCC API was very difficult to get started with in comparison, but it provided the most power and functionality if you wanted to build a Communicator replacement. Unlike the UCC API, the Lync API requires the Lync client to be running — it reuses the connection that the client has established with the Lync infrastructure. You can configure the Lync client to run in UI Suppression mode —where its user interface is invisible to the user — enabling you to build custom communications clients previously only possible when using the UCC API.

Lync Functionality – Using the Lync Controls in the Applications

Think of the Lync client as being built out of LEGO blocks, each providing a specific piece of functionality such as showing the presence of contacts, organizing contacts into groups, and interacting with contacts by starting instant message or phone conversations. The Lync controls separate the functionality in Lync clients into individual controls that developers can drag and drop into their Windows Presentation Foundation (WPF) or Silverlight applications.

The Lync controls include a control to show the presence of a contact; for example, the presence of a project manager in a CRM system. Controls are also available to easily start an instant message or audio conversation with that contact at the click of a button. With no additional code required.

A set of other controls provides functionality for managing contact lists; for example, to integrate the user’s Lync contact list into an application. You can also use custom contact lists to create and display an ad-hoc list of contacts, such as the account team for a client in a CRM application. Additional controls are available to search for contacts and display the results. Controls are also available to set the current user’s presence, personal note, and location.

Due to their obvious dependence on user interface elements of the Lync client, the Lync controls are not available in UI Suppression mode.

Integrating Lync functionality into applications using the Lync controls allows users to launch communications directly from the application that they are working in without needing to switch to the Lync client. The Lync controls are available in WPF and Silverlight and are extremely easy to use; you only need to drag and drop the appropriate controls into the application, and they work without the need for any additional code.

Communications – Using the Lync API in the Applications

The Lync API object model exposes extensibility points that allow developers to build applications that interact with the running instance of the Lync client. You can use the Lync API to programmatically sign a user into the Lync client and handle events for changes in its state. You can also start a conversation, add participants, handle conversation and participant events, and add contextual data to the conversation.

You can use the Lync API to create subscriptions on attributes of contacts in your contact list; for example, to track when the availability of a particular contact changes. The Lync API also provides functionality to modify attributes of users signed in to Lync, such as changing their presence or publishing a personal note or location.

Like the IMessenger API, the Lync API includes automation: the ability to start conversations in different modalities (such as instant message or audio/video) with a very small amount of code. The functionality in automation simply invokes the necessary Lync user interface elements, such as a Lync conversation that includes the Application Sharing modality so that a user can share her desktop with another user. Because it is dependent on Lync user interface elements, the functionality in automation is not available when the Lync client is running in UI Suppression mode.

In conjunction with the Lync controls, you can use the Lync API to easily add communications functionality into Silverlight, WPF, and Windows Forms applications. For example, you can spruce up a customer relationship management (CRM) application by integrating presence and click-to-call functionality, allowing users to accomplish their work without needing to switch back and forth between the application and the Lync client.

The Lync UI Suppression Mode

When the Lync client is configured to run in UI Suppression mode, its interface is completely hidden from the user. Applications that use Lync UI Suppression are responsible for recreating those user interface elements from scratch. The Lync API with Lync running in UI Suppression mode is the recommended development pattern for applications you would have previously built with the UCC API.

Lync UI Suppression requires that the Lync client is installed on the user’s machine; this eliminates the complexity of managing the connectivity of the application back to the Lync server infrastructure. In UI Suppression, you use the Lync API to replicate some of the functionality available in the Lync client, such as signing users into Lync, retrieving their contact list, and starting and responding to conversations in different modalities.

When working with UI Suppression, you interact with conversations at the modality level—activating individual modalities manually, creating conversations, adding participants, and disconnecting the modalities when the conversation is completed. For example, you can build a Silverlight instant messaging client that provides a completely customized user interface for instant message conversations. In this case, you would be responsible for recreating application functionality and user interface elements such as a contact list and conversation window. You would work directly with the instant message modality, creating a conversation, connecting the modality, sending instant message text to participants, notifying participants when someone is typing, and delivering the instant message text to the participants in the conversation.

Using the Lync API with Lync running in UI Suppression mode, you can build compelling Lync-replacement solutions such as a custom instant messaging client, or a dedicated audio/video conferencing solution.

Working with the UCMA

Although the Lync SDK is used to integrate communications functionality into applications that run on the client, UCMA is typically used to build communications applications that run on the server; for example, hosted in Internet Information Services (IIS), exposed through Windows Communication Foundation (WCF), or running in a Windows Service. A UCMA application is usually a long – running process such as an automatic call distributor used to handle and distribute incoming calls in a call center. Users interact with the UCMA application via an endpoint that can either be a contact in Lync, such as sip:HelpDesk@fabrikam.com, or simply a phone number. The user can start a Lync call, instant message with the UCMA application contact or dial the phone number associated with the application.

Consider the following scenario where Contoso, a fictitious company, uses a UCMA – based application to run its call center operations.

When customers call Contoso’s customer service phone number, the UCMA application picks up the calls and guides callers through a workflow, such as one built with the UCMA Workflow SDK, to gather information from them such as the reason for their call, their account number, and so on. After the workflow gathers the necessary information from the callers, it places them on hold and searches for an agent with the right skills to assist them. Customers remain on hold until an agent becomes available; the UCMA application tracks all the agents’ Lync presence so it knows when an agent becomes available again to handle a call.

When an agent picks up calls, he or she already knows a lot about the callers based on the information they provided. An Agent Dashboard application hosted in the Lync conversation window can display information about the caller such as order history or any open customer service tickets that require attention. The agent can use this information to provide better service to the customer.

An application such as the customer service Agent Dashboard is built using the Lync SDK, including the Lync controls and the Lync API. The UCMA application interacts with the Agent Dashboard using the Context Channel, a new feature in UCMA 3.0 that provides a channel across which a UCMA application and Lync SDK application can send information to each other. For example, if the agent realizes that he needs to consult another agent to help with the call, he can issue an “escalate” command from the Agent Dashboard application. The command is sent across the context channel to the UCMA application, which knows how to process it and look for another available agent with the necessary skills to assist with the call.

Part of a supervisor’s duties in Contoso’s customer service department is to monitor the performance of agents and coach them on how to provide better service to customers. The supervisor can launch a Supervisor Dashboard application that shows a list of all active calls. The supervisor selects a call to silently join, allowing him to monitor the call without the knowledge of either the customer or agent. The new audio routes functionality in UCMA 3.0 enables developers to build routes across which audio can travel in a conference, effectively controlling who can hear what. When the supervisor is monitoring a call, audio flows to her from the conference but doesn’t flow back in, allowing her to listen in to a call without being heard. If the supervisor needs to provide coaching to the customer service agent, an audio route is established from the supervisor to the agent, allowing her to “whisper” to the agent without the customer hearing any of the conversation.

UCMA 3.0 includes several other enhancements that are covered in more detail later in the book, including an easier development experience for working with presence and conferences, and a feature known as auto – provisioning, which greatly simplifies the process of managing the plumbing and configuration information required to run a UCMA application.

Building Workflow Applications with the UCMA Workflow SDK

You use the UCMA Workflow SDK to build communications – enabled workflow solutions such as IVR systems and virtual personal assistants. You typically use an IVR system to gather information from a caller such as the customer account number and reason for the call before connecting him or her to a live agent. A virtual personal assistant, on the other hand, provides services to the caller such as the ability to reserve a conference room from a mobile phone.

For a more concrete example, consider this scenario. In the legal industry, potential cases need be vetted for any conflicts of interest that could prevent the firm from being able to take on the case. This process is referred to as new matter intake, and each potential case is called a matter. Most law firms have software in place to streamline this process; however, such a solution can be extended to provide users with the ability to call in and check on the status of a new matter.

For example, an attorney could place a call to the New Matter Intake application contact in Microsoft Lync from her mobile phone. Using text – to – speech technology, the IVR prompts the attorney to enter her identification PIN and validates her identity. The IVR can then execute code to access the database, retrieve a list of outstanding matters for that attorney, and prompt her to select one. After the attorney selects a matter, the IVR can again access the database to identify the conflicts attorney assigned to the matter. The IVR can now check the presence of the conflicts attorney, and if he is available, ask the caller whether she wants to be transferred. The IVR can then perform a blind transfer of the call and disconnect itself from the call.

The UCMA 3.0 Workflow SDK enables developers to visually construct communications-enabled workflows by dragging workflow activities onto a design service, arranging and connecting them to form the workflow solution. You can construct workflows to accept audio or instant message calls, or both.

In the case of audio calls, input from the user can be in the form of dual-tone multi-frequency (DTMF) tones (choosing an option by entering its corresponding number using the phone’s keypad), speech recognition, or both. The text-to-speech engine, available in 26 different languages, converts text to prompts that the caller hears during different activities of the workflow. You can also substitute professionally recorded audio prompts to give the IVR a more polished feel.

The previous attorney example represents an incoming communications workflow; however, developers can also build outgoing communications workflows. For example, a person might receive an automated call from the Service Desk asking him to rate his experience with a ticket he recently opened. The communications workflow can ask him several questions, such as his satisfaction with how the ticket was handled, and then save the results of the survey to a database when the call is completed.

Workflows are a critical part of a communications solution, allowing the software to provide services to a caller and only transferring the call to a live customer service agent—the comparatively more expensive resource—if necessary and only after providing the agent with all the relevant information about the caller.

(Source: Professional Unified Communications Development with Microsoft Lync Server 2010 by George Durzi and Michael Greenlee)