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


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)[]). 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 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:


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

#.)Run Powershell for the Direct Routing trunk:
New-CsOnlinePSTNGateway -Fqdn -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


rp-fw-01*CLI> pjsip show history
No. Timestamp (Dir) Address SIP Message
===== ========== ============================== ===================================
00000 1584889159 * ==> OPTIONS SIP/2.0
00001 1584889160 * <== SIP/2.0 200 OK
00002 1584889160 * <== OPTIONS;transport=TLS SIP/2.0
00003 1584889160 * ==> SIP/2.0 200 OK
00004 1584889173 * <== INVITE sip:9000@ 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.

Hi Fully
First of all, thank you very much for your contribution.

I’m doing the same but I can’t get the calls answered and the RFER to work well.

would you be so kind to pass me your pjsip.conf and extension.conf file?

Thank you very much in advance.
My email is

hi there. i wrote a blog that may help with the config files.

If you go to my blog it is there.


@Fully what am i making wrong? I tryed hundreds of settings and stoped using your settings.
What i always get is:

00000 1588947197 * <==        INVITE;user=phone;transport=tls SIP/2.0
00001 1588947197 * ==>        SIP/2.0 100 Trying
00002 1588947197 * ==>        SIP/2.0 488 Not Acceptable Here

As far as i know this has something todo with encryption or not matched codes. I saw you playing around with silk16 too. I already tryed tls and the result is:

root@sipconnect:/etc/asterisk# openssl s_client -connect
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = LV, L = Riga, O = GoGetSSL, CN = GoGetSSL RSA DV CA
verify return:1
depth=0 CN =
verify return:1

This is the current config:




type = aor



Do you have other settings somewhere?

Hi lucderheld,
in my [msteams_trunk] I have
allow=ulaw, alaw, gsm

Maybe it’s worth a try, because 488 might be a codec issue.

Best regards

Hmm, no change :frowning:
What version of asterisk source did you compile? and where there other changed to sourcecode than the two changes in res_pjsip_nat.c? Maybee i will just start from beginning with a version that someone is using and which is working.

That’s our working complete solution with Asterisk 16.5.1:
Teams with Asterisk proof of concept

There should be a Warning header giving the reason for the rejection. Generally you need to provide the full text of the request and response, not just the method and status.

No warning, no message. Just nothing. Only with pjsip debug it was possible to get some output. Tryed with asterisk 16.5.1 but pjsip didnt even load:

loader.c:2396 load_modules: Error loading module ‘’: /usr/lib/asterisk/modules/ undefined symbol: ast_sip_cli_traverse_objects

so giving up on thins project. But thanks that you tryed to help!

Please read or increase the detail of output from the tool that you used to produce the protocol trace,and come back when you have the full text of the 488 response packet.

The undefined symbol suggests you are trying to load a copy of which was not compiled against the same options and versions as the main Asterisk build.