MSPL Script How-to

Microsoft SIP Processing Language [MSPL], is a scripting language that you can use to customize how Lync Server handles and routes SIP messages. MSPL scripts run in the context of the Lync Server process itself (in the front end), so they can intercept messages between users, filter messages, reroute messages, and so on.

MSPL unlike UCMA applications, they don’t run as a separate process, nor do they create endpoints of their own. they aren’t limited to controlling messages to and from a single endpoint it deals with all endpoints of that Lync Server.

How you can decide to use MSPL or UCMA?

  1. MSPL
    • The MSPL code itself is included directly in the application manifest.
    • The MSPL modifies the Front End behavior of the Lync Server. It has control over every message that is proxied through the Front End Server, regardless of where it comes from which endpoint or where it goes.
  1. UCMA
    • The UCMA application runs on a separate server from Lync Server, and creates an endpoint which communicates with other Lync endpoints via the Lync Front End Server.
    • The UCMA application can participate in and control a conversation between the remote endpoint and itself but can’t control other conversations between other endpoints that are not in the same conversation.


MSPL Script Structure

The following is the form that your MSPL script must be which is an ordinary XML file. The application Manifest is an XML file can be edited using any XML editor, Text editor or even you can open it using Microsoft Visual Studio, so you will find it started with the xml declaration, The following script to filter the sip requests that used to join conference as follow:

<?xml version="1.0" ?>


    <!-- Define properties of the application -->
    <lc:requestFilter methodNames="INVITE" 
    <lc:responseFilter reasonCodes="NONE" />
    <lc:proxyByDefault action="true" />

    <!-- The message filtering script -->

if (sipRequest && (sipRequest.Method == StandardMethod.Invite)) 
    if (sipRequest)
        Log("Event", false, "Joined the conference");
	DispatchNotification("OnRequest", sipMessage.To);


MSPL Script Syntax


the root element of the MSPL script is the <lc:applicationManifest> it contains the appUri attribute, which is basically a unique identifier for your application and you need it when you installing your application to the Lync Server.

<lc:requestFilter methodNames="INVITE" strictRoute="false"/>

Using the <lc:requestFilter> you can control what types of messages this application should handle so it controls the types of requests. it contains the methodNames attribute which can contains a list of SIP method names separated by commas i.e. invite also can monitor ALL method names or NONE of them. the next one is strictRoute attribute, which is false by default, controls whether the application sees requests for which explicit routing details have already been specified. If this is set to true, these messages that have a “strict” route will also go through the application.

<lc:responseFilter reasonCodes="NONE" />

The <lc:responseFilter> also specify what types of messages this application should handle and contain The reasonCodes attribute holds a comma-delimited list of SIP response codes, or ALL, or NONE.

<lc:proxyByDefault action="true" />

The <lc:proxyByDefault> element, which is used to decide how application will handle the sip message by setting the action attribute, If this is set to false, any messages that are not proxied, responded to, or otherwise handled by the application are simply dropped. If it’s true, messages that are not handled are proxied to their destination by Lync Server, just as they would were the application not installed.

<lc:scriptOnly />

If application will consist only of an MSPL script, and will not use any managed code, we can add the <lc:scriptOnly /> element, if not there is no need to add it.

    <![CDATA[ /* Start writing your script here */ ]]>

After that The MSPL script itself is included in the manifest within the <lc:splScript> element.

if (sipRequest) {
    /* do something */
    Log("Event", false, "Log somthing - ", sipMessage.To);
if (sipResponse) {
    /* do something else */

If you need to access the message. The sipMessage variable provides access to a class that contains the message details. However, in many cases, the application’s behavior will depend on whether it is handling a request or a response; and the data available will depend on which type of message it is. the same as sipResponse if you want to access the response.

Helpful References


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