Lync / S4B redirect all calls from a give external number to a single number internally

I want to take all calls that arrive on a Lync 2010 / Skype for business site from a defined external number and send them to a single internal number, ignoring the originally called internal number.
One site on premise, one Lync 2010 pool with 99% of the users in it a and a migration Skype for Business 2015 pool with one test user.
LVL 16
Carol ChisholmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Greg BessoIT Solutions EngineerCommented:
One server-side way to do this is to start using MSPL scripts on your Lync or SfB server. You can do this pretty easily actually. There are a few steps involved but basically it is...

1) Create a new network shared folder, you might have one already just for Lync. Either way, something like \\server\share\LyncFiles\CallForwarding.

2) Within this share, create a new CallForwarding.am file. It's a text file that you just rename to something like that.

3) For the contents that you need to put IN that file, look at this URL for example: https://msdn.microsoft.com/en-us/library/office/dn439073.aspx

In that example, just look for the lines with toUri = ... and then fromUri = ... and the If statement below it. One way is to remove those sections and replace with something like...

toUri = GetUri(sipRequest.To);
toUserAtHost = Concatenate(GetUserName(toUri), "@", GetHostName(toUri));
telNum = GetUserName(toUri);

if ((ContainsString(toUserAtHost, "+12125551212@YourDomain.com", true)) ){   Respond("302","Moved Temporarily","Contact=<sip:SomeDestinationSipPerson@YourDomain.com>");    return;}
if ((ContainsString(toUserAtHost, "+12125551213@YourDomain.com", true)) ){   Respond("302","Moved Temporarily","Contact=<sip:SomeDestinationSipPerson@YourDomain.com>");    return;}

// at end have some way to exit back to Lync processes if not caught already...
return;


4) Then once your file is setup, you need to create an application on your pool that uses it. Something like the following in the Lync PowerShell for example...
New-CsServerApplication –Identity "registrar:YourPool.YourDomain.com/CallForwarding" –Uri http://YourDomain.com/CallForwarding -ScriptName "\\Server\Share\LyncFiles\CallForwarding\CallForwarding.am" –Critical $False –Enabled $False

5) Then you just go into the web admin console and enable that new server application you created. Click Topology > Server Application. Highlight this new CallForwarding item, and click Actions > Enable.

It's a lot to get familiar with if you haven't used this stuff before, but it's way easy once you review it and see that it's just a text file, with one line for each # you are redirecting, and voila. Hope that is helpful.
0
Greg BessoIT Solutions EngineerCommented:
OH and I should mention, whenever you want to choose to forward additional #'s you just edit the .am file and save/close it. It should then take effect quickly. You can stop/start that server application also to speed it up.
0
Carol ChisholmAuthor Commented:
Thanks I will read the link,
In your example you use YourDomain.com

((ContainsString(toUserAtHost, "+12125551212@YourDomain.com", true)) ){   Respond("302","Moved Temporarily","Contact=<sip:SomeDestinationSipPerson@YourDomain.com>");    

I want to reroute  ALL incoming calls from a given external number independent of the destination. I'm not clear how that works in your example.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Carol ChisholmAuthor Commented:
Any perhaps I am not clear but this is no IM but Enterprise voice from a PSTN so there won't be any SIP information, just a number.
0
Carol ChisholmAuthor Commented:
I also have an Audiocodes gateway perhaps it would be easier to do it there?
0
Greg BessoIT Solutions EngineerCommented:
Yes sure thing. So the +12125551212@YourDomain.com is how an incoming phone # to your internal users will be seen by the system. The phone # is where they are calling you from. Before it gets to your Lync users, that is how the # is seen as. SO if your Lync pool for users is cchisholm@contoso.com and someone at +12125551212 is calling your EV #, and you want to instead have calls go to someone else, you just do something like...

if ((ContainsString(toUserAtHost, "+12125551213@contoso.com", true)) ){   Respond("302","Moved Temporarily","Contact=<sip:TheOtherPersonThatWantsToGetThisCall@contoso.com>");    return;}

It's weird looking, since you are redirecting the call to a Lync user so using their SIP address and not a phone #.
0
Carol ChisholmAuthor Commented:
What's an EV# ?

Seeems amazingly complicated... So my xml file should contain this?

<?xml version="1.0"?>
<r:applicationManifest
   r:appUri="http://www.contoso.com/ForwardInvite"
   xmlns:r="http://schemas.microsoft.com/lcs/2006/05">
   <r:allowRegistrationBeforeUserServices/>
   <r:serverFilter roles="ALL"/>

   <!-- handle INVITE requests -->
   <r:requestFilter methodNames="INVITE"
                 strictRoute="false"
                 registrarGenerated="true"
                 domainSupported="true"/>

   <!-- handle no response. -->
   <r:responseFilter reasonCodes="NONE"/>

   <!-- Script-only application. -->
   <r:scriptOnly/>

   <r:splScript><![CDATA[
     if (!sipRequest) {
       return;
     }
     toUri = GetUri(sipRequest.To);
     fromUri = GetUri(sipRequest.From);

if ((ContainsString(toUserAtHost, "+12125551213@contoso.com", true)) ){   Respond("302","Moved Temporarily","Contact=<sip:TheOtherPersonThatWantsToGetThisCall@contoso.com>");    return;}

     }
     ProxyRequest("");
   ]]></r:splScript>
</r:applicationManifest>
0
Greg BessoIT Solutions EngineerCommented:
EV means your enterprise voice phone #. I would say that you test this out in a test environment and get familiar with the basics, but I just uploaded my CallForwarding.am file that I used in the past. It has a couple of other statements you can ignore, just look at the one or two lines where it has the phone #'s that you would replace with yours.

https://github.com/gregbesso/LyncCallForwarding
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Chat / IM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.