Microsoft Lync and Skype for Business have a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use those APIs.

New MSPL function in Lync 2013: RetargetRequest

Posted: November 23rd, 2012 | Author: | Filed under: MSPL | Tags: , , | 2 Comments »

Microsoft SIP Processing Language (or MSPL), a part of the Lync Server SDK, is a fantastic and currently underused tool for overriding or extending Lync routing behaviour to meet business needs. I’ve written about some of its capabilities and how to use it in previous blog posts. It’s handy for things like intercepting and blocking calls with certain characteristics, filtering messages, logging or monitoring communications, or rerouting calls to different destinations. It’s also probably the Lync API that has remained the most unchanged from version to version. In Lync 2013, it’s managed to hang on to this distinction, with only a couple of additions, but one of them is really quite interesting and potentially useful, and I wanted to bring it to everyone’s attention here. The new RetargetRequest method allows you to have an MSPL script change the destination a message is going to, but without bypassing the rest of the scripts that are installed on the Lync server.

In previous versions of MSPL, the way to change the destination of a SIP request in order to affect routing behaviour was to use the ProxyRequest method. You could do something like this, for example, to route a SIP message to a specific endpoint:


The trouble with this approach is that it skips all of the other server applications, some of which are actually built in to Lync, like Outbound Routing, which helps determine where outbound PSTN calls get sent, or the Intelligent IM Filter (the thing that filters URLs in instant messages). If you set up your MSPL script to run after these other applications, your script may never get hit at all; but if you set it up to run before, you may mess up features that are provided by these built-in applications or by others that are also installed on the servers.

RetargetRequest avoids this problem by changing the target of the SIP request without cutting short the processing of the message. The other MSPL applications on the server can then also process it and modify it or reroute it as necessary. So if you change the code above to


you can accomplish essentially the same change to the routing, but allow the other server applications to continue functioning normally.

This is definitely a useful addition to the SDK.

2 Comments on “New MSPL function in Lync 2013: RetargetRequest”

  1. 1 Cassie said at 4:58 pm on November 29th, 2012:

    Hi Michael,

    Would like to discuss possible consultant help (mostly Q&A for now) for some Lync 2010/2013 work we would like to start?

    Are you open to that? If so, can you contact to discuss.


  2. 2 Ganesan said at 7:52 am on December 16th, 2015:

    Hi Michael,

    We are sending the request in Managedcode using Request.Retarget() to our ApplicationEndpoint , but our UCMA application endpoint is not receiving anything .How to verify whether the request is dispatched to our application endpoint from Lync Front end Server? you have any ideas? we are stuck at this, any help will be of greatly appreciated.
    Ganesan S

Leave a Reply

  • Note: Comment moderation is in use because of excessive spam. Your comment may not appear immediately.