Apply online

Microsoft 365 Teams Direct Routing Configuration

In this article

Introduction

At the end of this article, you will be able to integrate your Microsoft Teams users from within your Microsoft 365 account, to your flexible call flow manager. Utilising Microsoft Teams as your main business communication tool, whilst adding the additional functionality of the unified communications of Microsoft Teams, video conferencing, video calling, collaboration and more. This guide will step you through the entire process. Should you need any assistance, feel free to contact our support department.

Microsoft 365 licensing requirements

The first step is to ensure all your Microsoft Teams users have the Enterprise licensing assigned to them. (See image below for example of User having a license assigned.)

mceclip2.png

While we have tested that the Office 365 E5 and Enterprise E5 subscriptions have 'Phone Standard' in built, other subscriptions of Microsoft Office may allow this add-on to be applied. To order the Teams Phone Standard license, click on the billing button from the toolbox menu on the left, select purchase services, then locate and order the Teams Phone Standard license. Repeat the previous step to add the freshly ordered Teams Phone Standard license to your Microsoft 365 users.

Please note: Not all subscriptions have this add-on available. If you require help, please refer to Microsoft Support for assistance.

teams_purchase_licenses.png

Please also note the Microsoft 365 Phone Standard - Virtual User addon license is not compatible with Office 365 user accounts.

Custom domain setup

Now you have the correct licensing assigned to your Microsoft Teams users, we will start the process of configuring the PSTN gateway, known as direct routing, between your Microsoft 365 tenancy and your PBX. Login to your Microsoft 365 account as a global administrator, select Setup and then View under 'get your custom domain set up'.

teams4.jpg

Click on the manage button to add a new domain.

teams5.jpg

Click on the add domain button, this will produce a setup wizard which will allow you to enter the FQDN details from your customer portal. Now revert to your customer portal.

teams6.jpg

Login to your customer portal, click on the order services tab and then the Microsoft Teams button on the left-hand side.

mceclip0.png

Copy the Microsoft 365 FQDN address which will be in the following format sbcXXXXX.XX.voipcloud.online. Please double-check the information is correct and then click on the "use this domain" button.

TXT record

Next, you will be prompted to verify the domain that you have entered. Office 365 defaults to signing into Cloudflare. Select More options, and then select 'Add a TXT record to the domain's DNS records'

domain2.png

Microsoft 365 will provide you with a value for a TXT record confirmation. Copy the full value of this record. Do not attempt to press the verify button until you have added the TXT record to your customer portal.

domain3.png

Enter the text record into the "Office 365 TXT record" field within your customer portal. Now, you will need to start adding your Microsoft Teams users and selecting a phone number to assign to each. The number assigned may contain no relevance as it will be utilised for communications between your PBX and Microsoft 365 tenancy only. Add at least one user and phone number, read and agree to the service terms and conditions, then submit the order.


Please note, without a Microsoft Teams user and phone number, you will not be able to verify the domain inside your Microsoft 365 portal. Also, note the phone number assigned to your Microsoft Teams user will automatically be sent to the associated Microsoft Teams user if it is not configured in the PBX call flow

mceclip0.png

Going back to your Microsoft 365 portal click the verify button.


teams9__1_.jpg


Once the domain verifies,you will be asked how you want to connect your domain. Select more options, and then 'Add your own DNS records'

domain4.png

Ensure everything is unticked.

domain5.png

And then select 'Done' to complete this part of the setup

We must now activate the domain. This is an essential step to integrate both systems, make sure you do not skip it. On your Microsoft 365 admin centre, you should select users from the left-hand menu and click on active users. After that, you should add a user and enter the required details, making sure you select the correct domain from the drop-down window. This will be in the formatsbcXXXXX.XX.voipcloud.online.


Please note, creating an alias for an existing user will not activate the domain. You must create a new user for activating the domain which can be removed once the domain has been activated.

teams12.jpg

Lastly, you should ensure that a product license is assigned to this user. The license can be any license that contains Microsoft Teams, such as Enterprise E1 and Business Basic and does not need to include the Phone Stanard add-on. The domain will not activate without a license assigned. This license can even be reassigned temporarily from another user if a spare license is not available. Finally, hit the next button and complete the activation.

teams13.jpg

Direct Routing Options

There are two different routing setups you can do when using Microsoft Teams direct routing.

Option 1. You can set up using our Hosted PBX and inbound direct all call traffic via User devices. With this option, you can use our full host of features to create call flows.

Option 2. You can set up using a SIP Trunk and direct all inbound call traffic via an MS Teams gateway. With this option, you set up all call flow requirements within the MS Teams environment.
Below you will find the setup instructions for both.

(Option 1) Hosted PBX User & MS Team Device License Setup

To start the process of ordering users and devices, you will need to log into your customer portal and select the order services tab.

Then, click the add button which will apply a new user and remove the single SIP device.

It is possible to add multiple SIP devices per user, should you need more than one device per user. For example, you would like an MS Teams user and theiroffice handset assigned to the same call plan.

Next, read and agree to the service terms and conditions and submit the order, as shown in the screenshot below.
mceclip1.png

We will now add your Microsoft Teams accounts to a user object or SIP trunk inside your PBX. You will utilise a user object if you require the PBX functionality, and a SIP trunk if you would like Microsoft 365's phone system to handle your calls. This is an important requirement that must not be skipped, as all Microsoft Teams accounts will require a call plan for outbound calls to be placed. To start, click the settings icon on your user object.

teams17.JPG

Click the add button then the option "Microsoft Teams Integration".

Select the Microsoft Teams email address from the drop-down list that you would like to assign. Save the configuration and don't forget to apply the new configuration.

(Option 2) SIP Trunking Setup

Alternatively, if you would like to use Microsoft 365's phone system, we will add your Microsoft Teams accounts to your SIP trunking object, click the settings icon of your SIP trunk.

teams22.JPG

Opt for the 'Microsoft Teams gateway' mode.

Ensure you have a call plan assigned. Click on the add button and select your Microsoft Teams accounts, save the configuration and don't forget to apply the configuration.


Please, note that blind transfers to call parking slots will not work as expected by using Microsoft Teams. For further information or guidance on the PBX configuration please view our extensive knowledge base which has a range of articles to support your system requirements.

Configuring Powershell

We will now connect your Microsoft 365 tenancy to your PBX using the direct routing functionality. To begin, click on the Windows key located in the bottom left of the toolbar, search for PowerShell, then right-click and select run as an administrator. When launching the application as an administrator, the system might request authorization to run on your computer, click on yes and the PowerShell screen will appear.

teams14.jpg


You will now be presented with the PowerShell window to run the following configuration commands.


mceclip0.png

Next, we will require the Microsoft Teams module. For this, run the following command in PowerShell, as shown in the image below.

Install-Module -Name MicrosoftTeams -RequiredVersion 4.5.0

2.JPG

Please note there are known issues with PowerShell 7 and Teams PowerShell. For the best experience, we recommend that you use PowerShell 5.1.

After this, you may need to change the Powershell script execution policy by running the following command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Once done, please close and re-open Powershell before proceeding with the rest of the setup

Before running any Teams setup commands, you must start a session connecting to the account in which the domain has been configured by running the following command:

Connect-MicrosoftTeams

3.JPG

After that, a window will pop up and you should enter your Microsoft Administrator credentials and proceed with the next commands.

5.JPG

Configuring the direct routing gateway

From your customer portal locate and copy the FQDN used in the custom domain section of this guide.

Now, run the command below replacing sbcX.YY.voipcloud.online with your custom FQDN from your customer portal. (shown in above screenshot)
This will create the PSTN gateway.

New-CsOnlinePSTNGateway -Fqdn "sbcX.YY.voipcloud.online" -SipSignalingPort 5061 -SendSipOptions $false -Enabled $true -ForwardCallHistory $true -ForwardPai $true

Please note that If you receive a 'domain not configured for this tenant' error, check to see if you have activated the sbcx.yy.voipcloud.online domain with a licensed user (see the custom domain section of this guide for further details). If you have activated the domain with a licensed user, please wait as Microsoft 365 domain activation can take some time.

Then, create an empty PSTN usage;

Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="VC PSTNUsage"}

Next, create a voice routing policy;

New-CsOnlineVoiceRoutingPolicy -Identity "VC VoiceRoutingPolicy" -OnlinePstnUsages "VC PSTNUsage"

And the final command to create the voice route, and associate with the PSTN usage,sbcX.YY.voipcloud.online with your custom FQDN from your customer portal;

New-CsOnlineVoiceRoute -Identity "VC VoiceRoute" -NumberPattern ".*" -OnlinePstnGatewayList sbcX.YY.voipcloud.online -Priority 0 -OnlinePstnUsages "VC PSTNUsage"

The domain setup is now complete and we will continue to set up the Microsoft Teams users.

Enable calling on your Microsoft Teams users

We now have the custom domain configured and the direct routing gateway connected to your Microsoft 365 gateway, next we must enable PSTN calling functionality for your Microsoft Teams users. Login to your customer portal, locate and copy each of the numbers you have assigned to each of your Microsoft Teams user accounts.


blobid27.png


Run the command below in PowerShell, where "Teams email address" is your Microsoft Teams email address and "Phone Number" is the phone number associated from your customer portal.
Please note: The 'phone number' needs to be in the same format as the customer portal (Eg: 61xxx)
Press enter once you have copied and adjusted the command.

This command is for the Teams module above 3.0.0 version

Set-CsPhoneNumberAssignment -Identity "email address" -PhoneNumber "Phone number" -PhoneNumberType DirectRouting

Please note that If you see this message:

"BadRequest User 'long string of hexadecimal characters' lacks appropriate licenses to assign a 'DirectRouting' number"

Then the user does not have the required license. Please check the Microsoft 365 licensing requirements section of this guide for further details

If you are unsure about what version of the Teams Powershell module you are currently using, you can check by running

Get-InstalledModule

Assign the default voice policy. Copy to PowerShell and return once the placeholder has been updated with your Microsoft Teams email address.

Grant-CsOnlineVoiceRoutingPolicy -Identity "Teams email address" -PolicyName "VC VoiceRoutingPolicy"
Please note in the above command the policy name refers back to the policy created as part of creating the direct routing gateway. If you receive an error saying the policy 'is not a user policy', run the following command to determine what your existing voice routing policy has been called:
Get-CsOnlineVoiceRoutingPolicy

You have now successfully enabled calling functionality on your Microsoft Teams user. Repeat the process with all your additional Microsoft Teams users. Finally, restart your Microsoft Teams client and you will be presented with the dial-pad functionality under the calls tab. It is now highly recommended to adjust the dial plan and disable the standard voicemail, to improve the usability of Microsoft Teams.


Please note, on rare occasions the Microsoft 365 platform can take up to 48 hours for the synchronization to complete and the dial-pad to appear.

teamsdialpad.jpg

Adjusting the dial plan

By default, Microsoft Teams will add the + symbol before any call made by the users. If the country code is not dialled after that, it might cause an error or you may be unable to make the call. Enter the command below to PowerShell.

New-CsTenantDialPlan -Identity "Voip dial plan" -Description "Pass all numbers to PBX"


We now have a new dial plan. Next, we will add our normalization rules, and enter the following commands to PowerShell;

$rule1 = New-CsVoiceNormalizationRule -parent "Voip dial plan" -name "Match all digits without plus" -description "pass everything through" -pattern '^(.*)$' -translation '$1' -inmemory
Set-CsTenantDialPlan -identity "Voip dial plan" -NormalizationRules @{add=$rule1}

At this stage, you will have a normalization rule which will match with any number dialled. We now need to assign this dial plan to each of your Microsoft Teams users. Enter the command below, where "email address" is replaced with your Microsoft Teams email address.

Grant-CsTenantDialPlan -Identity "email address" -policyname "Voip dial plan"

Repeat the process with all your Microsoft Teams users

Watch this in action

gif.gif



A quick search will help you find answers to most of the FAQ's.
If you are unable to find a solution from the knowledge base centre, please contact your service provider for technical assistance.