Microsoft Teams integration possible?

Hi All,

I would like to start looking into integrating our in-house Asterisk phone system with Microsoft Teams.

i would like to know if this is possible and if anyone has achieved this, also what features we can integrate.

many thanks

Russ

I’m pretty sure Teams only supports “Direct Routing”, which uses a supported SBC to trunk between your carrier and Microsoft. The PBX functionality is provided by them.

Hey, I want to revive this thread! I was also searching for an answer to this question and stumbled across this post, which describes in detail how to connect Asterisk to Teams.

At first, I also thought the only way is to purchase a certified SBC solution to link Asterisk to Microsofts “Direct Routing”, but it seems like there are other ways than that.

The above linked tutorial is on the Microsoft Teams configuration side identical in wide parts with the official guide (see (here)[https://docs.microsoft.com/microsoftteams/direct-routing-configure]). So it seems like even though Microsoft promotes certified SBCs from selected vendors, technically nothing stands in the way to connect Asterisk directly to MS Teams.

Microsoft only states at the guide:

Microsoft only supports Phone System if a certified device or devices are connected via Direct Routing. Microsoft reserves the right to reject support cases where a non-certified device is connected to the Phone System via Direct Routing.

So a first step in the right direction would be to make the CONTACT and VIA headers of SIP options packets configurable, so they fit the needs of MS Teams to include the FQDN there.

I just found this thread, so it seems like there is already someone on it. Maybe @lima25 can say something regarding this topic?

OR you can put OpenSIPS as SBC in front of Asterisk to connect with MS Teams

P.S. Please note that I haven’t tried or tested this

Oh you’re right, didn’t notice that! Also Kamailio seems to work just fine (see here). Nevertheless it’s another instance that has to be understood, configured and maintained. From my perspective having one instance is still desirable :wink:

We’ve done a proof of concept and got it working, but with a dirty code hack.
Please consider, that I wouldn’t use it in a critical productive environment. Details can be seen here:

It at least should help to understand, what has to be done and where the pitfalls are.

Run a production multi tenanted service for teams on asterisk, its just sip really.
Although as others have mentioned teams integration is really at the sbc level, on my platform the integration is done at the edge, and proxied to the Voice DMZ so asterisk is oblivious to the mutual TLS and SRTP requirements and just receives standard SIP messages and RTP streams like it would from any other trunk or carrier.

Only thing you have to be careful of is maintaining the use of e.164 format numbers through out the call flow, as teams (just like SfB before it) only supports DID’s in that format, unless you have a rewriting step on your sbc and then translate to and from extension numbers.

Thanks to ayonik.de for getting my POC started with their notes. I now have a fully working Asterisk to Direct Routing MS Teams trunk. I only use it for POC/demos at work but if you are interested in learning more about Asterisk and Microsoft Teams it is a good place to start. I know very little about Asterisk so I have only put together a config just to be able to test. I can share my config and learnings in the hope of helping someone else out. Only abbreviated notes but happy to help if you are stuck. Also happy to take advice on how I could do it better. I’m not looking to boil the ocean.

Started here:

Topology:

Poly D230 Dect Cordless IP Handset ==>Asterisk==>Direct Routing==>MS TEams==>Poly CCX 500 Teams Handset or Laptop(s)

So pretending D230 Dect is on the PSTN with e.g.+61755551000 and MS TEams Handset/Laptop has Dummy +61755559000. Testing Call forking inbound to ring another D230 and MS Tams at the same time. and vicy versa.

#.)Recompiled Asterisk (first on Asterisk 17.0.1 but now on 17.3 due to intermittent / dodgy failing on refer on transfer with SIP). So I would start with Asterisk 17.3 and recompile with headers that match your DNS name for the Asterisk “SBC” (using term loosely) to Microsoft Teams direct routing trunk.

#.)Make sure you have a valid cert. I use LetsEncrypt 90 day certs as they are free for testing.

#.)Setup a trial or test O365 tenant with E5 licenses etc if you can get it.

#.)Setup DNS correctly. My SIP SBC is sipconnect.o365.fullys.xyz

#.)Run Powershell for the Direct Routing trunk:
New-CsOnlinePSTNGateway -Fqdn sipconnect.o365.fullys.xyz -SipSignallingPort 5061 -MaxConcurrentSessions 10 -Enabled $true

#.)There are other powershell commands to run like dialplan and Set-CsUser settings etc.

#.)Edit pjsip.conf (Here is mine - may look weird to some seasoned Asterisk pros but it works) - Not all these settings seem to impact the trunk but you can play and see.

Looks like new users are blocked from posting more than 2 URLs and no uploads :frowning:

So ping me and Ill send you my notes I typed and configs for pjsip and extensions conf.

#Note: No NAT in between Asterisk and Poly D230 sip handset. Asterisk on Raspberry pi4 (on the NBN Gateway to internet). Using Nftables as much easier so reach out if stuck on that front.

#.)Debug :slight_smile:

sudo asterisk -vvvvvr
pjsip set history on
core set debug 5
core set verbose 5
pjsip set logger on
pjsip show history
pjsip show history entry 56

e.g.

rp-fw-01*CLI> pjsip show history
No. Timestamp (Dir) Address SIP Message
===== ========== ============================== ===================================
00000 1584889159 * ==> 52.114.14.70:5061 OPTIONS sip:sip.pstnhub.microsoft.com SIP/2.0
00001 1584889160 * <== 52.114.14.70:5061 SIP/2.0 200 OK
00002 1584889160 * <== 52.114.14.70:7177 OPTIONS sip:msteams_trunk_from_teams@sipconnect.o365.fullys.xyz:5061;transport=TLS SIP/2.0
00003 1584889160 * ==> 52.114.14.70:7177 SIP/2.0 200 OK
00004 1584889173 * <== 192.168.90.128:5060 INVITE sip:9000@10.88.10.5:5060 SIP/2.0

My Asterisk report an s@msteams unreachable so I added this

;To allow Remote Attended Transfers
exten => external_replaces,1,NoOp()
exten => s,1,Dial(PJSIP/msteams_trunk/${SIPREFERTOHDR})

In MS Teams portal the Directing Trunk kept reporting that Asterisk was not replying etc to Options packets.

Adding this resolves that and make the status 100% ok:

; to react on incoming SIP Options Packets with an “200 OK”
; Without this MSTeams portal shows SIP OPTIONS Errors
exten => msteams_trunk_from_teams,1,HangUp()

NOTE: both above and previous command for transferring a call were placed in the extensions.conf file.