Tech

PBX for Microsoft Teams: Complete Step-by-Step Integration

Published on:

April 17, 2020

To integrate the Vodia PBX with Microsoft Teams, you need to configure both systems to enable seamless communication. First, set up a domain in the Vodia PBX, create Teams-specific extensions and configure a SIP trunk for Teams. In Microsoft Teams, configure Direct Routing by creating a PSTN gateway for the PBX, enabling users for enterprise voice services and assigning routing policies through PowerShell. This integration allows Teams users to act as extensions on the PBX, enabling features like call groups and voicemail while maintaining SIP phone support for non-Teams users.

Microsoft Teams offers an unprecedented feature set for office communication. The integration of Vodia with Teams allows for Vodia extensions and MS Teams extensions to seamlessly communicate with each other. Additionally, MS Team members can belong to hunt groups or agent groups, as well as receive and make outbound calls, all from the Vodia PBX. Employees who have no need to take advantage of utilizing MS Teams can still have a registered SIP phone, so they can still be called from a Teams extension via direct routing.

You can review the complete installation on YouTube or follow the guide below

You can use the “Direct Routing” feature of Office 365 (Teams) to integrate with the Vodia PBX, as explained on the Microsoft website here:

https://docs.microsoft.com/en-US/microsoftTeams/direct-routing-configure

“Plan Direct Routing” and “Configure Direct Routing”

This document gives you a single, simplified, step-by-step process for integrating with the Vodia PBX, including the steps required on the Vodia PBX side.

Prerequisites

  1. Microsoft Teams, Office 365 account here
  2. A domain in Office 365 with a FQDN (fully qualified domain name) you own
  3. User(s) in Office 365 with at least an E3 or E5 license or a license that supports direct routing (not all users need to have these licenses - free trial available here).
  4. Vodia PBX software with Teams integration (introduced in version 64.1)
  5. A domain (which is FQDN) in the Vodia PBX with a valid certificate

Vodia PBX setup for integration with Teams Office 365

For the Vodia PBX to send calls to Teams users: 

  1. Create a domain in the Vodia PBX with an FQDN (fully qualified domain name) you own
  2. Create the Teams extensions in that domain
  3. Create a Teams trunk in that domain
  4. Create a general trunk in that domain for the trunk calls and set it accordingly

1. Create a domain in the Vodia PBX

Go to the domain list. Press “Create” to add a new domain. Give it a name that’s an FQDN that: 

  • Resolves to the Vodia PBX
  • The domain part of which is the same as the domain you create in the Office 365 account (explained in the Teams Office 365 section of this document)
  • Has a valid certificate

Since in this example we will create a domain called “company.com” in Teams (below), we can use the FQDN “pbx.company.com” for the domain name in the Vodia PBX (the domain part of which, i.e., “company.com”, is the same as the domain name created in Teams). This FQDN, “pbx.company.com”, should reach the Vodia PBX and will be used by Teams to connect to the PBX; this is explained in the Teams section (below). It must also have a valid certificate, which can be added in the certificates section. Or if the “Let’s encrypt” setting on Vodia PBX is on, it will be created for you automatically. A new domain, “pbx.company.com”, will appear in the PBX domain list.

2. Create the Teams extensions in that domain

  • Go to the domain pbx.company.com you created in step 1, by clicking on it
  • Go to “Extensions” under “Accounts”
  • Press “Add”
  • Enter the extension number (it must be the same as the telephone number you will give to the corresponding Teams user in Office 365 - this is explained in the Office 365 section) - this is how the PBX will map this extension to the Teams Office 365 user - press “Create” to create the extension
  • The extension will appear in the list. Click on it to enter the extension settings. Under the “General” tab, change the setting “Extension feature set” to “Teams”, and save
  • Similarly, make sure all the extension numbers are mapped to the Teams Office 365 users with the same number

3. Create a Teams trunk in that domain

  • Go to the domain “pbx.company.com” you created in step 1 by clicking on it
  • Go to “SIP Trunks” under Trunks
  • Add a trunk by pressing the “Add” button
  • Select the provider as “Teams”
  • For “User name”, give a friendly name (say “Teams”)
  • Press “Create”
  • The new “Teams” trunk will appear in the list
  • Click on it for setup - set the setting, "Country code", to your country code

Once you have also set up Teams, as explained in Teams section below, you should be able to make and receive calls to/from Teams users on this trunk. In this example, we will use the default setup (i.e., without changing anything except the country code). Teams users (with their extension numbers) will act as the PBX extensions as they are mapped to the PBX extensions.

4. Create a general trunk for the trunk calls and set it up accordingly

Create a general trunk for trunk calls, the same as in step 3, but choose your SIP trunk of choice (and NOT Teams) and give it another name for general calls. It will be used for your outgoing and incoming trunk calls as they are normally used.

This new trunk will appear in the list. Click on it to enter, then set it up accordingly like any trunk on the PBX. For example, you can set it for all incoming calls going to a specific account like “Auto Attendant” or “ACD”; from these accounts they can be distributed to different extensions, including mapped Teams users, etc. 

Also like any trunk, the “Dial plan” uses this trunk for outbound calls.

Teams Office 365 setup for integration with Vodia PBX

  1. Log in to your Teams Office 365 account and create your domain there with the FQDN you own (e.g., company.com)
  2. Create users under the domain and assign them E3, E5 or a relevant license that supports “Direct Routing”
  3. Use PowerShell to connect to your Office 365 account with your login and password
  4. Using PowerShell, create a PSTN gateway to connect to the Vodia PBX using the FQDN of the domain you create in the Vodia PBX - with a valid certificate
  5. Using PowerShell, enable the user for direct routing service by configuring the phone number and enabling enterprise voice and voicemail for the user; the user should now be able to receive calls from the Vodia PBX
  6. Using PowerShell, configure voice routing for outgoing calls to the Vodia PBX.

1. Create your domain in your Office 365 tenant

Use your browser (if not using premises installation): log in to your Office 365 admin account and create your domain. In “Microsoft 365 admin center”, go to “Setup”, then press the “View” button for the “Get your custom domain set up”, then the “Manage” button - add a domain there. Choose a proprietary domain name (e.g., company.com), since it will be verified by Microsoft once you paste a value in the TXT value field of your DNS or by signing into the account where you got the domain, etc. it is important you own the domain and can perform the verification process. Once this is done, the domain will be created and you can add users to it.

2. Create users in this domain

Now you can create users under the domain you just created in step 1 above. Again, in “Microsoft 365 admin center”, go to “Active users” - under “Users” and “Add a user”. Provide the first and last name of the user (“John Smith”); under “username" give a unique name that will be his/her email, but make sure to choose the domain you created above for the domain part of the username (company.com in this example) and not the default company.onmicrosoft.com or any other (i.e., *.onmicrosoft.com) - this way the user resides in the domain you just created in step 1 above (in this example, say js@company.com).

3. Use PowerShell to Connect to your Office 365 account

  • In the powershell cmd type Install-Module MicrosoftTeams to install the Teams module

It’s explained on the Microsoft site here. Just the portion “Connect using a Skype for Business Online administrator account name and password” should be enough, unless you want to do more.

4. Create a PSTN gateway that will connect to the Vodia PBX

Before you use PowerShell, make sure it’s the right one, and connected to the right account, as you did in step 3 above. To confirm step 3 was done correctly use the command:

  • Get-Command *onlinePSTNGateway*

Your command will return the four functions shown here so you can manage the SBC.

CommandTypeNameVersionSource

  • FunctionGet-CsOnlinePSTNGateway1.0tmp_v5fiu1no.wxt
  • FunctionNew-CsOnlinePSTNGateway1.0tmp_v5fiu1no.wxt
  • FunctionRemove-CsOnlinePSTNGateway1.0tmp_v5fiu1no.wxt
  • FunctionSet-CsOnlinePSTNGateway1.0tmp_v5fiu1no.wxt
Create PSTN Gateway to connect Teams to Vodia

Using PowerShell, create a PSTN gateway to connect to the Vodia PBX using the FQDN of the domain you create in the Vodia PBX with a valid certificate.

The domain portion of this FQDN must match the domain registered in your tenant as in step 1 above (e.g., it can be: pbx.company.com, since the domain you created was company.com). It’s also important there is an Office 365 user in that domain (as you did in step 2 above, a user in company.com) and an assigned E3 or E5 license. If not, you will receive an error: “Cannot use the ‘pbx.company.com’ domain as it is not configured for this tenant”.

This FQDN (pbx.company.com) must resolve to a reachable IP of the Vodia PBX. Also, this FQDN (pbx.company.com, in this example) must be a domain in the Vodia PBX. Creating a domain in the Vodia PBX is explained in the Vodia PBX section - you must make sure a DNS A record is made for this domain (e.g., pbx.company.com) that will reach the Vodia PBX. Also, a valid certificate must be added in the Vodia PBX for this domain. It is fortunately very easy to get a valid certificate if the “Let’s Encrypt” setting is on; all you have to do is create the domain and a Let’s Encrypt certificate will be added to it automatically.

The PowerShell command example to create the PSTN gateway:

New-CsOnlinePSTNGateway -Identity pbx.company.com -Enabled $true -SipSignalingPort 5061 -MaxConcurrentSessions 100

Of course, use your own domain. Returns:

  • Identity : pbx.company.com Fqdn : pbx.company.com
  • SipSignallingPort : 5061 FailoverTimeSeconds : 10
  • ForwardCallHistory : False ForwardPai : False SendSipOptions :
  • True MaxConcurrentSessions : 100 Enabled : True

You can check this gateway’s parameters at any time:

Get-CsOnlinePSTNGateway -Identity pbx.company.com

Returns:

  • Identity : pbx.company.com Fqdn : pbx.company.com
  • SipSignallingPort : 5061 CodecPriority : SILKWB,SILKNB,PCMU,PCMA ExcludedCodecs :
  • FailoverTimeSeconds : 10 ForwardCallHistory : False ForwardPai :
  • False SendSipOptions : True MaxConcurrentSessions : 100 Enabled :
  • True

5. Enable the user for direct routing service

Direct Routing requires the user to be domiciled at Skype for Business Online. You can check this via the RegistrarPool parameter - it needs to have a value in the infra.lync.com domain.

PowerShell command:

Get-CsOnlineUser -Identity "<User name>" | fl RegistrarPool

For our example:

Get-CsOnlineUser -Identity "John Smith" | fl RegistrarPool

Using PowerShell, enable the user for direct routing service by configuring the phone number and enabling enterprise voice and voicemail for the user.

Set-CsUser -Identity "<User name>" -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:<E.164 phone number>

For our example:

Set-CsUser -Identity "John Smith" -OnPremLineURI tel:4002 -EnterpriseVoiceEnabled $true -HostedVoiceMail $true

OR

Set-CsUser -Identity "js@company.com" -OnPremLineURI tel:4002 -EnterpriseVoiceEnabled $true -HostedVoiceMail $true

Notice the number for our example is a 4-digit number, but it could be a full E.164 number. We want to use the users as extensions (4002 is the extension for this user) that can connect and can be connected as an extension between Teams and the Vodia PBX: PSTN or SIP trunk inbound and outbound calls can be handled by the Vodia PBX trunk, just like any PBX, and users on Teams can act as extensions of the PBX. You can easily use other setups and scenarios, however, and assign the full E.164 numbers (with country code) to the users.

Note: It can take some time between creating a user in Teams and being able to change its setting here with "Set-CsUser", so you may have to wait an hour or two if it gives you errors such as “the user does not exist”. You have to make sure the user email (or name) is correct.

The user should be able to receive calls from the Vodia PBX now, either from extensions on the PBX itself or from PSTN and SIP trunks, set up within Vodia PBX, as the case may be.

6. Configure voice routing for outgoing calls to the Vodia PBX

Now you can configure the rules as to when to use the PSTN gateway setup in step 4 above to route the call to the Vodia PBX.

As explained in the Microsoft document, the Microsoft Phone System has a routing mechanism that allows a call to be sent to a specific SBC based on:

  • Called number pattern
  • Called number pattern + Specific User who makes the call

Call routing:

  • Online PSTN Gateway: Connects to the SBC or PBX (in this case, the Vodia PBX); it also stores the configuration that’s applied when a call is placed via the SBC, such as forward P-Asserted-Identity (PAI) or Preferred Codecs (it's used by Voice Routes)
  • Voice Route: Uses online PSTN Gateways for calls where the calling number matches the pattern
  • PSTN Usage: Uses Voice Routes and other PSTN Usages - different Voice Routing Policies can use it
  • Voice Routing Policy: Uses PSTN Usages - can be assigned to a user or to multiple users

In summary:

User -> Voice routing policy -> PSTN usage -> Voice route -> PSTN gateway

In our example, since we designate the user as a Vodia PBX extension, we want the call to arrive there first and use the dial plans in the PBX for routing calls. Other scenarios are easily implemented as well. For this simple one, let’s create:

John Smith (User)-> Policy1 (Voice policy) -> Usage1 (PSTN usage) -> pbx.company.com (PSTN gateway)

Let’s create the usage first, as it will be used in the route:

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

To find out available usages:

Get-CSOnlinePSTNUsage

Let’s create the route using the Vodia PSTN gateway and the above usage:

New-CsOnlineVoiceRoute -Identity "Route1" -NumberPattern "^\+(\d{4})|^(\d{4})" -OnlinePstnGatewayList pbx.company.com -Priority 1 -OnlinePstnUsages "Usage1"

The command creates a route, “Route1”, where Teams passes the call to PSTN gateway pbx.company.com (a domain in the Vodia PBX) if the dialed number has at least 4 numbers (based on our example here, where we want to give each user a 4-digit extension, but it’s up to your setup), with or without a + sign. This way, you can dial a 4-digit extension or an E.164 number with country code and the + sign. 

Of course, multiple routes can be created with different priorities.

To find out different routes, use:

Get-CsOnlineVoiceRoute

Let’s create a voice policy using the same usage to which our PSTN gateway is linked above:

New-CsOnlineVoiceRoutingPolicy "Policy1" -OnlinePstnUsages "Usage1"

The result:

  • Identity : Tag:Policy1 OnlinePstnUsages : {Usage1} Description : 
  • RouteType : BYOT

You can of course create a policy with several PSTN Usages, but we’ll keep it simple with our example.

Let’s grant our user, John Smith, our voice policy:

Grant-CsOnlineVoiceRoutingPolicy -Identity "js@company.com" -PolicyName "Policy1"

You can check the policy assignment with this command:

Get-CsOnlineUser "js@company.com" | select OnlineVoiceRoutingPolicy

Now the outbound dialing policy and routing are complete, so John Smith can call out. In this example, the outbound call will end up in your Vodia PBX domain, pbx.company.com.

In our example, we could set up your domain in the Vodia PBX (see the Vodia PBX section):

  • If that extension (4 digits in this case) exists in your Vodia PBX domain and is registered, it will be called from your Office 365 user, whether it's a SIP desktop phone registered to your Vodia domain, the Vodia desktop app, a Vodia web app or the Vodia smartphone app.
  • If that extension doesn’t exist (say it’s an E.164 10 digit number, etc.), then Vodia will route the call to a PSTN gateway or SIP trunk so the call can go out.

Microsoft Teams Webinar Slide Presentation

Latest Articles

View All

The Vodia PBX Is Now Certified for Microsoft Teams

Vodia is excited to announce that its PBX is now certified for Microsoft Teams, enabling seamless voice integration with Teams’ collaboration tools. This certification allows Teams users to leverage advanced PBX features, such as call routing, auto attendants, voicemail, and more, while ensuring secure and high-quality voice services. The integration also supports various industries like hospitality, healthcare and manufacturing, where Teams users can now make and receive calls via Vodia’s certified SBC. With the Vodia PBX, organizations can streamline their communication processes and reduce costs while ensuring continuity and flexibility across all channels.

November 19, 2024

VoIP for Enterprises: Vodia Streamlining your Communications

Vodia’s enterprise VoIP solution provides a versatile and scalable communications platform tailored to businesses of all sizes. The Vodia PBX enables high-quality VoIP calls, with features like scalability, robust security and a range of rich functionalities. Its adaptability across devices and cloud environments makes it highly flexible for diverse IT infrastructures. For hybrid workplaces, Vodia’s system supports multiple network interfaces, eliminating the need for VPNs by enabling seamless communication for remote and on-site staff. Integrating easily with major SIP-based devices and third-party tools Vodia helps enterprises streamline their workflows with unified communications across voice and messaging.

November 12, 2024

Vodia Ring Groups - An Overview

The Vodia PBX provides businesses with a comprehensive telephony solution designed for both on-premise and cloud systems, offering features like audio conference rooms, auto attendants, voicemails, call forwarding, and ring groups. A ring group, or hunt group, directs incoming calls to designated team members using strategies like simultaneous or sequential ringing, ensuring calls reach an available agent quickly. Vodia’s PBX supports multi-stage call routing, customizable ring melodies, CRM integration, and options like music on hold and call recording. Ideal for enterprises managing low-volume call groups, Vodia’s system enhances accessibility and call management efficiency for businesses worldwide.

November 7, 2024