Skip to main content

Introduction to Direct Routing - Knowledgebase / Microsoft Teams Direct Routing - Help & Support

Introduction to Direct Routing

Authors list

Introduction to MS Teams Direct Routing

Setting up phone calling for Microsoft Teams using our Direct Routing configuration couldn't be easier. Our PowerShell wizard integrates directly into your Teams account to automate and simplify what is otherwise a complicated setup. Our only prerequisites are your Teams Domain and Teams Phone licensing and we handle the rest: DNS, users, phone numbers, PSTN and routing information.

Useful guides before you start

1. Set up licensing for users

Enabling phone services for Microsoft Teams requires specific licensing for each user:

  • Enterprise licensing: add either an E1, E3, or E5 license for a user and this will give you the functionality you need to enable phone services for that user.

  • Teams Phone Standard: this add-on is a requirement to enable a phone service. Any license that has Microsoft Teams included can purchase a Teams Phone Standard license to enable phone services.

Here's where to set this up:

  1. Sign into Microsoft 365 admin center (as an admin).
  2. Select Billing > Licenses.

2. Adding Teams-enabled numbers

Back on 2talk's portal, if you're adding new numbers to your account, go to Switchboard, select Add Number and follow the instructions. Check out the Adding Numbers article for more information. Otherwise, or once the new numbers have been added, you can follow the next steps.

  1. Log into your account.

  2. Go to Switchboard and select the number you want to use MS Teams with.
  3. Under the Number Details tab, select Teams in the Type dropdown.

  4. Click on Save to apply the changes to the number.

3. Connect your 2talk & Microsoft accounts

Use our PowerShell wizard to generate the necessary pwsh scripts to complete your Direct Routing setup.

  1. Go to Tools > Teams.

  2. Select PowerShell to open the step-by-step instructions. The first page will get you started on how to use PowerShell with Microsoft Windows and macOS operating systems.

3.1 Connect to MS Graph

Open a PowerShell window and connect to your Microsoft 365 tenant using the Microsoft Graph API.

#: Install-Module Microsoft.Graph #: Connect-MgGraph -Scopes "User.ReadWrite.All","Domain.ReadWrite.All"

3.2 Create Domain

Use the New-MgDomain cmdlet to add a domain.

#: New-MgDomain -BodyParameter @{Id="ms50000100.teams.2talk.com";IsDefault="False"}

3.3 Get TXT Record

#:$MgVerificationCode = (Get-MgDomainVerificationDnsRecord -DomainId "ms50000100.teams.2talk.com" | Where-Object {$_.RecordType -eq "Txt"}).AdditionalProperties.text
#: echo $MgVerificationCode

Domain validation TXT record: this record is generated by Microsoft to validate your unique address against our DNS. Copy and paste the record into Add TXT dialog to insert the record.

3.4 Confirm the domain

You need to confirm the domain with Microsoft. Run this command: 

#:Confirm-MgDomain -DomainId "ms50000100.teams.2talk.com"

Following confirmation, we will remove the TXT record from our Cloudflare DNS.

Important: we have provided a 5-minute window to complete this step. If you're unable to confirm the domain in the allocated time, you can repeat this confirmation step at a later date.

4. Create Users

  • Go to the Microsoft Admin Center, then Users and Add a user.

  • Temp User: Microsoft requires a “temporary user” to associate with the trunk domain. This temporary user requires a Office 365 Business license.

  • Trunk domain: Select from the dropdown menu (e.g. sbc@ms50000100.teams.2talk.com).

  • Click Next.

MS Teams - Add New user

5. Create PSTN

  • Go to Tools > Teams.

  • Select PowerShell.

5.1 Connect to MS Admin

Open a PowerShell window and connect to your Microsoft 365 tenant using the Microsoft Graph API.

#: Install-Module Microsoft.Graph
#: Connect-MgGraph -Scopes "User.ReadWrite.All","Domain.ReadWrite.All"

5.2 Create PSTN Gateway

Use the New-CsOnlinePSTNGateway cmdlet to create a PSTN gateway. You'll need to specify the parameters required for the gateway, including the FQDN (Fully Qualified Domain Name) and other configuration details.

#: New-CsOnlinePSTNGateway -FQDN ms50000100.teams.2talk.com -SIPSignalingPort 5061 -MaxConcurrentSessions 100 -Enabled $true

5.3 Verify the PSTN Gateway

Use New-CsOnlinePSTNGateway to verify that the PSTN gateway has been created.

#: Get-CsOnlinePSTNGateway

6. Associate Users

6.1 Connect to MS Admin

Open a PowerShell window and connect to your Microsoft 365 tenant using the Microsoft Graph API.

#: Install-Module Microsoft.Graph
#: Connect-MgGraph -Scopes "User.ReadWrite.All","Domain.ReadWrite.All"

6.2 Routing configuration

Paste the commands to set up the PSTN identity and Voice route details.

#: Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="VOIP"}
#: New-CsOnlineVoiceRoute -Identity "VOIP" -NumberPattern ".*" -OnlinePstnGatewayList "ms50000400.teams.2talk.com" -Priority 1 -OnlinePstnUsages "VOIP"
#: New-CsOnlineVoiceRoutingPolicy -Identity "VOIP" -OnlinePstnUsages "VOIP"

6.3 Associate users

If you have more than a single user, you will need to map a phone number to each of your Teams users using the following commands. The example below assumes that our example user, joe@2talk.com, is going to be assigned the phone number +1 (310) 635-1799, using the Identity of “VOIP”.

Replace the following commands as required for your own circumstances.

#: Set-CsPhoneNumberAssignment -Identity joe@2talk.com -PhoneNumber +13106351799 -PhoneNumberType DirectRouting
#: Grant-CsTeamsCallingPolicy -PolicyName AllowCalling -Identity joe@2talk.com
#: Grant-CsOnlineVoiceRoutingPolicy -Identity joe@2talk.com -PolicyName "VOIP"
#: Set-CsOnlineVoicemailUserSettings -Identity joe@2talk.com -VoicemailEnabled $false

6.4 Disconnect from MS Teams (optional)

Optionally, run the following command to disconnect your PowerShell instance.

#: Disconnect-MicrosoftTeams

All good! Your 2talk account should be all set and connected back to your Microsoft 365 account.

Microsoft Teams, Microsoft Windows and PowerShell are trademarks or registered trademarks of Microsoft Corporation in the US and other countries. macOS is a registered trademark of Apple Inc.

Helpful Unhelpful

Share