Fix External Call forwarding in Direct Routing with Microsoft Teams – AudioCodes Mediant SBC with SIP Trunk


When Direct Routing with Microsoft Teams has been deployed, you will notice that forwarding and transferring calls to PSTN numbers might not work. But, if the PSTN connection is an ISDN trunk or anything TDM, this will work from the get-go.

The reason behind this is, both Skype for Business and Teams sends original caller ID, when a call get forwarded or transferred to PSTN. The original caller ID will be the CLID of the PSTN inbound call. If the PSTN connection is a SIP Trunk, then the trunk won’t allow outbound calls from a source number that does not belongs to it’s number range. It will reject the call.

Below is a SYSLOG capture of a call that getting forwarded to PSTN. Notice the FROM field. That is a Mobile number. HISTORY INFO carries the DID that forwarded the call.

If the PSTN connection is a TDM trunk, then it will mask the caller ID to the pilot number of the trunk and process the call. In this article, i’m going to explain how to fix PSTN call forwarding to work with SIP Trunks.

In my setup, i have Direct Routing configured in AudioCodes Mediant 800 SBC. I have a SIP Trunk from a local telecommunications provider for PSTN connectivity. So, let’s start.

1st thing you need to do is, enable “ForwardCallHistory” in OnlinePSTN Gateway. Log in to Skype for Business Online Powershell and run the command. By default, it turned off;

Set-CsOnlinePSTNGateway -Identity <FQDN of the GW> -ForwardCallHistory $True

Log in to AudioCodes SBC and create a Message Manipulation rule to manipulate the FROM User URI to replace it with the Pilot number of the SIP trunk. Unfortunately, we can’t get the actual DID number that sets the call forward as that information is not there in INVITE header. The Manipulation Set ID mentioned below can be any value. I had to use “5” as i’m already using 1-4 for different rules. Action Value should be the Pilot number of the Trunk. 

After that, set the Manipulation set ID in Teams IP group, “Inbound Message Manipulation” setting.

This should fix the number inbound number presentation in to SIP Trunk. If you look at a SYSLOG capture,it will show how the numbers are getting presented to SIP trunk. Notice that the FROM number have changed from +614xxxxxxxxx mobile number to 089xxxxxxx value, that was set in Message Manipulation. This number was manipulated to remove “+61” and add “0” by an “Outbound Message Manipulation” rule. 

By now, call forwarding to PSTN should work. If it still having issues, check the SYSLOG of a failed calls to identify what could be the root cause. Post in comments if you still have issues with PSTN call forwarding setup in Teams (with Direct Routing).

Leave a comment