Microsoft Teams integration possible?

Sorry, it was a long day trying to get this work. I recompiled everything AND ITS WORKING NOW! Thanks for your help!

For any others that have this problem. I did this before ./configure:

cd contrib/scripts
./install_prereq install
./install_prereq install-unpackaged

The install-unpackaged gave me some wired error messages, but it compiled poperly at the end.

The only thing i have problem with is DTMF. It is not working when calling someone with microsoft teams. I read some posts that it is only possible with alaw and ulaw (which i use) and that payload type need to be set to 101. But there are much discussions that payload on 101 isnt usal and correct. I think i could search in the source files of pjsip for the payload types and recompile everything. Did someone of you did DTMF get to work?

Payload 101 is used for telephony events, in which case the main codec doesn’t matter. You only need to use Mu-Law or A-law if you are sending the tones in band, rather than as events.

The type number for telephony events is not fixed. Each side tells the other which it intends to use. However 101 is the default preference for Asterisk.

This thread still lives ?

Did my own POC using chan_sip instead. Still trying to figure out how to REFER and OPTIONS ping. Hope this can help at some point.

https://www.otakudang.org/?p=969

Hmm chan_sip would maybee an option to try. I will maybee do it if there is no more options with PJSIP. I do not want to give up. Calling via teams is possible now without problems. But call someone in teams does not work. I always get Q.850;cause=95;text=ā€œNo SDPā€. Which means something like ā€œunspecific errorā€. Any suggestions what I could check? I was reading about not sending ā€œREFERā€ in INVITE request.But i didnt found an option to turn it of. This is the trace:

-- Executing [4930863xxxxx@rya-incomming:2] Set("PJSIP/rya-incomming-00000000", "CALLERID(dnid)=+49017323xxxxx") in new stack
-- Executing [4930863xxxxx@rya-incomming:3] Set("PJSIP/rya-incomming-00000000", "CALLERID(num)=+49017323xxxxx") in new stack
-- Executing [4930863xxxxx@rya-incomming:14] Verbose("PJSIP/rya-incomming-00000000", "Route MSNs") in new stack
Route MSNs
-- Executing [4930863xxxxx@rya-incomming:15] Dial("PJSIP/rya-incomming-00000000", "PJSIP/+4930863xxxxx@msteams_trunk_from_teams") in new stack
-- Called PJSIP/+4930863xxxxx@msteams_trunk_from_teams

<--- Transmitting SIP request (730 bytes) to TLS:52.114.75.24:5061 --->
INVITE sip:+4930863xxxxx@sip.pstnhub.microsoft.com SIP/2.0
Via: SIP/2.0/TLS sipconnect.x.de:7489;rport;branch=z9hG4bKPjab0a5728-1715-4b24-acf6-116e6e2a02de;alias
From: <sip:+49017323xxxxx@sipconnect.x.de>;tag=10a4140c-d693-424a-9a09-1e3294642e8a
To: <sip:+4930863xxxxx@sip.pstnhub.microsoft.com>
Contact: <sip:asterisk@sipconnect.x.de:7489;transport=TLS>
Call-ID: efa61b05-fd5f-408e-ba5d-8287ee6effbe
CSeq: 7497 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 16.5.1
Content-Length:  0

<--- Received SIP response (474 bytes) from TLS:52.114.75.24:5061 --->
SIP/2.0 100 Trying
FROM: <sip:+49017323xxxxx@sipconnect.x.de>;tag=10a4140c-d693-424a-9a09-1e3294642e8a
TO: <sip:+4930863xxxxx@sip.pstnhub.microsoft.com>
CSEQ: 7497 INVITE
CALL-ID: efa61b05-fd5f-408e-ba5d-8287ee6effbe
VIA: SIP/2.0/TLS sipconnect.x.de:7489;branch=z9hG4bKPjab0a5728-1715-4b24-acf6-116e6e2a02de;rport;alias
CONTENT-LENGTH: 0
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY
SERVER: Microsoft.PSTNHub.SIPProxy v.2020.5.6.2 i.EUWE.5

<--- Received SIP response (548 bytes) from TLS:52.114.75.24:5061 --->
SIP/2.0 400 Bad Request
FROM: <sip:+49017323xxxxx@sipconnect.x.de>;tag=10a4140c-d693-424a-9a09-1e3294642e8a
TO: <sip:+4930863xxxxx@sip.pstnhub.microsoft.com>
CSEQ: 7497 INVITE
CALL-ID: efa61b05-fd5f-408e-ba5d-8287ee6effbe
VIA: SIP/2.0/TLS sipconnect.x.de:7489;branch=z9hG4bKPjab0a5728-1715-4b24-acf6-116e6e2a02de;rport
REASON: Q.850;cause=95;text="1c2462aa-cd47-453a-a718-15745b78087f;No SDP"
CONTENT-LENGTH: 0
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY
SERVER: Microsoft.PSTNHub.SIPProxy v.2020.5.6.2 i.EUWE.5

<--- Transmitting SIP request (458 bytes) to TLS:52.114.75.24:5061 --->
ACK sip:+4930863xxxxx@sip.pstnhub.microsoft.com SIP/2.0
Via: SIP/2.0/TLS sipconnect.x.de:7489;rport;branch=z9hG4bKPjab0a5728-1715-4b24-acf6-116e6e2a02de;alias
From: <sip:+49017323xxxxx@sipconnect.x.de>;tag=10a4140c-d693-424a-9a09-1e3294642e8a
To: <sip:+4930863xxxxx@sip.pstnhub.microsoft.com>
Call-ID: efa61b05-fd5f-408e-ba5d-8287ee6effbe
CSeq: 7497 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 16.5.1
Content-Length:  0

  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [4930863xxxxx@rya-incomming:16] Hangup("PJSIP/rya-incomming-00000000", "") in new stack
  == Spawn extension (rya-incomming, 4930863xxxxx, 16) exited non-zero on 'PJSIP/rya-incomming-00000000'

<--- Transmitting SIP response (439 bytes) to UDP:195.185.37.60:5060 --->
SIP/2.0 603 Decline
Via: SIP/2.0/UDP 195.185.37.60;rport=5060;received=195.185.37.60;branch=z9hG4bKCWh~DaamzHAk~
Call-ID: SBCd415e00009f5-5eb800e4-19152d91-2fca3508-93e0ab9-01_b2b-1
From: <sip:017323xxxxx5@sip.easybell.de>;tag=51D47450-5EB800E4000DFF68-A5D38700
To: <sip:4930863xxxxx@sip.easybell.de>;tag=8df2dcc2-a328-41e3-ad19-73acdc5721d9
CSeq: 10 INVITE
Server: Asterisk PBX 16.5.1
Reason: Q.850;cause=95
Content-Length:  0

<--- Received SIP request (397 bytes) from UDP:195.185.37.60:5060 --->
ACK sip:4930863xxxxx@sipconnect.x.de:7488 SIP/2.0
Via: SIP/2.0/UDP 195.185.37.60;branch=z9hG4bKCWh~DaamzHAk~;rport
From: <sip:017323xxxxx5@sip.easybell.de>;tag=51D47450-5EB800E4000DFF68-A5D38700
To: <sip:4930863xxxxx@sip.easybell.de>;tag=8df2dcc2-a328-41e3-ad19-73acdc5721d9
Call-ID: SBCd415e00009f5-5eb800e4-19152d91-2fca3508-93e0ab9-01_b2b-1
CSeq: 10 ACK
Content-Length: 0

It says ā€œNo SDPā€, and that is true. I find that surprising, as I would expect early offer to be used, and can’t find anything to override that In any case, late offer is perfectly valid, so there is no valid reason for Teams to reject the call, at that point.

Solved it. I had silk16 in the allow option. Removed it an only left alaw and ulaw and now suprisingly it is working. I couldnt hear somethin on the called side but solved this with:

rtp_symmetric=no
force_rport=no
rewrite_contact=no

Hi all guys!

I did all on the tutorial but I have one question now, in pjsip history I can see 200ok from options bidirectionaly with my server and microsoft server (with TLS ok). But in the web i stil have this:

image

What could be the problem?

Thanks in advance!

I have the same question / problem.

I can make teams calls through asterisk. My problem is in receiving the calls in teams through asterisk.

Hello,

I can make teams calls through asterisk. My problem is in receiving the calls in teams through asterisk.

Could you share with me your trunk settings (msteams_trunk_from_teams).Ā“cause whne I try make a call, show congestion…

tks

Hello… I have the same problem…

Did you found the solution?

Hi Gallego,

Im working with this pjsip.conf for incoming calls:

[msteams_trunk_in]
type = endpoint
transport=transport-tls
context = msteams_in
disallow = all
allow = ulaw, alaw, gsm
media_encryption=sdes

[ident_msteams_trunk_in]
type=identify
endpoint=msteams_trunk_in
match=sip-all.pstnhub.microsoft.com

Hi All,

Fairly new to the forum. Have a couple of asterisk servers connected to a bunch of different Teams tenants.

Only thing i am really struggling with at the moment is attended transfers.

I have the following rules in my config, but the external replaces line does not seem to be called when doing a attended transfer.

exten => external_replaces,1,NoOp()

exten => s,1,Dial(PJSIP/msteams_trunk_out/${SIPREFERTOHDR})

Looking for some help on how to configure this properly. At the moment the connection is broken and the user receiving the transfer gets a new call with the user that should be transferred in it.

Any help would be appreciated, if paying for it is necessary that will not be a problem.

I’ve not used this feature since it was introduced, but it seems to me that it is only invoked if the destination isn’t within the same instance of Asterisk.

The second line isn’t going to get executed, as it is in a completely different extension.

Hi everyone!

I know it is kind of an old thread, but I’m trying to run this integration with MS Teams now, and so far I make all the modifications and configurations but when I make a call from MS Teams to Asterisk I get this:

<— Received SIP request (1980 bytes) from TLS:52.114.148.0:8256 —>
INVITE sip:+59322999999@development.contactvox.com:5061;user=phone;transport=tls SIP/2.0
FROM: Luis Aguirresip:+59326001001@sip.pstnhub.microsoft.com:5061;user=phone;tag=65765415782345498b24c63d57a3fca3
TO: sip:+59322999999@development.contactvox.com:5061;user=phone
CSEQ: 1 INVITE
CALL-ID: d256eb0dbf1953b7a8044d597ae2d807
MAX-FORWARDS: 70
VIA: SIP/2.0/TLS 52.114.148.0:5061;branch=z9hG4bK1aedc16
RECORD-ROUTE: sip:sip-du-a-us.pstnhub.microsoft.com:5061;transport=tls;lr
CONTACT: sip:api-du-c-uswe2.pstnhub.microsoft.com:443;x-i=96816af3-b3ca-424e-b0bc-0d4e24786e17;x-c=d256eb0dbf1953b7a8044d597ae2d807/d/8/b4fcd0413d0e4850bb92c492b61a0563
CONTENT-LENGTH: 1104
MIN-SE: 300
SUPPORTED: timer
USER-AGENT: Microsoft.PSTNHub.SIPProxy v.2021.4.12.3 i.USWE2.0
CONTENT-TYPE: application/sdp
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY
SESSION-EXPIRES: 3600

v=0
o=- 36093 0 IN IP4 127.0.0.1
s=session
c=IN IP4 52.115.186.230
b=CT:10000000
t=0 0
m=audio 51192 RTP/SAVP 104 9 103 111 18 0 8 97 101 13 118
c=IN IP4 52.115.186.230
a=rtcp:51193
a=ice-ufrag:8jSE
a=ice-pwd:zZ3NduK+AkJGIVXtoDJvj+io
a=rtcp-mux
a=candidate:1 1 UDP 2130706431 52.115.186.230 51192 typ srflx raddr 10.0.140.0 rport 51192
a=candidate:1 2 UDP 2130705918 52.115.186.230 51193 typ srflx raddr 10.0.140.0 rport 51193
a=candidate:2 1 tcp-act 2121006078 52.115.186.230 49152 typ srflx raddr 10.0.140.0 rport 49152
a=candidate:2 2 tcp-act 2121006078 52.115.186.230 49152 typ srflx raddr 10.0.140.0 rport 49152
a=label:main-audio
a=mid:1
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:s713eCg06AqND7TrD6M4w9r37KLOWhal6KFO+eRz|2^31
a=sendrecv
a=rtpmap:104 SILK/16000
a=rtpmap:9 G722/8000
a=rtpmap:103 SILK/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:97 RED/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:13 CN/8000
a=rtpmap:118 CN/16000
a=ptime:20

== Setting global variable ā€˜SIPDOMAIN’ to ā€˜development.contactvox.com’
<— Transmitting SIP response (445 bytes) to TLS:52.114.148.0:8256 —>
SIP/2.0 100 Trying
Via: SIP/2.0/TLS 52.114.148.0:5061;rport=8256;received=52.114.148.0;branch=z9hG4bK1aedc16
Record-Route: sip:52.114.148.0:8256;transport=TLS;lr
Call-ID: d256eb0dbf1953b7a8044d597ae2d807
From: ā€œLuis Aguirreā€ sip:+59326001001@sip.pstnhub.microsoft.com;user=phone;tag=65765415782345498b24c63d57a3fca3
To: sip:+59322999999@development.contactvox.com;user=phone
CSeq: 1 INVITE
Server: ContactVox
Content-Length: 0

<— Transmitting SIP response (2356 bytes) to TLS:52.114.148.0:8256 —>
SIP/2.0 200 OK
Via: SIP/2.0/TLS 52.114.148.0:5061;rport=8256;received=52.114.148.0;branch=z9hG4bK1aedc16
Record-Route: sip:52.114.148.0:8256;transport=TLS;lr
Call-ID: d256eb0dbf1953b7a8044d597ae2d807
From: ā€œLuis Aguirreā€ sip:+59326001001@sip.pstnhub.microsoft.com;user=phone;tag=65765415782345498b24c63d57a3fca3
To: sip:+59322999999@development.contactvox.com;user=phone;tag=3a668590-7a41-4176-82cb-090280c27151
CSeq: 1 INVITE
Server: ContactVox
Contact: sip:development.contactvox.com:5061;transport=TLS
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 3600;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length: 1566

v=0
o=- 36093 2 IN IP4 186.4.249.199
s=ContactVox
c=IN IP4 186.4.249.199
t=0 0
m=audio 25220 RTP/SAVP 8 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:5x+LBWHdZ6tTAlGb//BIOJdN1NA/TFx6ksB3bZNG
a=ice-ufrag:693cef3c51efee30433a65582a328a2e
a=ice-pwd:52c3f15f006a397b547354f803932219
a=candidate:H58d9741 1 UDP 2130706431 2800:bf0:1c9:301b:90d2:bff:fecd:6b27 25220 typ host
a=candidate:Hf6fdf047 1 UDP 2130706431 fe80::90d2:bff:fecd:6b27 25220 typ host
a=candidate:H432b4d41 1 UDP 2130706431 fe80::42:41ff:fef6:a726 25220 typ host
a=candidate:H22f2893f 1 UDP 2130706431 fe80::4cfa:ff:fee6:4454 25220 typ host
a=candidate:Hc0a864dc 1 UDP 2130706431 192.168.100.220 25220 typ host
a=candidate:Hac110001 1 UDP 2130706431 172.17.0.1 25220 typ host
a=candidate:Sba04f9c7 1 UDP 1694498815 186.4.249.199 32868 typ srflx raddr 192.168.100.220 rport 25220
a=candidate:H58d9741 2 UDP 2130706430 2800:bf0:1c9:301b:90d2:bff:fecd:6b27 25221 typ host
a=candidate:Hf6fdf047 2 UDP 2130706430 fe80::90d2:bff:fecd:6b27 25221 typ host
a=candidate:H432b4d41 2 UDP 2130706430 fe80::42:41ff:fef6:a726 25221 typ host
a=candidate:H22f2893f 2 UDP 2130706430 fe80::4cfa:ff:fee6:4454 25221 typ host
a=candidate:Hc0a864dc 2 UDP 2130706430 192.168.100.220 25221 typ host
a=candidate:Hac110001 2 UDP 2130706430 172.17.0.1 25221 typ host
a=candidate:Sba04f9c7 2 UDP 1694498814 186.4.249.199 32871 typ srflx raddr 192.168.100.220 rport 25221
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Received SIP request (718 bytes) from TLS:52.114.148.0:8256 —>
ACK sip:development.contactvox.com:5061;transport=TLS SIP/2.0
FROM: Luis Aguirresip:+59326001001@sip.pstnhub.microsoft.com:5061;user=phone;tag=65765415782345498b24c63d57a3fca3
TO: sip:+59322999999@development.contactvox.com;user=phone;tag=3a668590-7a41-4176-82cb-090280c27151
CSEQ: 1 ACK
CALL-ID: d256eb0dbf1953b7a8044d597ae2d807
MAX-FORWARDS: 70
VIA: SIP/2.0/TLS 52.114.148.0:5061;branch=z9hG4bK391fb879
CONTACT: sip:api-du-c-uswe2.pstnhub.microsoft.com:443;x-i=96816af3-b3ca-424e-b0bc-0d4e24786e17;x-c=d256eb0dbf1953b7a8044d597ae2d807/d/8/b4fcd0413d0e4850bb92c492b61a0563
CONTENT-LENGTH: 0
USER-AGENT: Microsoft.PSTNHub.SIPProxy v.2021.4.12.3 i.USWE2.0
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY

<— Received SIP request (861 bytes) from TLS:52.114.148.0:6336 —>
BYE sip:development.contactvox.com:5061;transport=TLS SIP/2.0
FROM: Luis Aguirresip:+59326001001@sip.pstnhub.microsoft.com:5061;user=phone;tag=65765415782345498b24c63d57a3fca3
TO: sip:+59322999999@development.contactvox.com;user=phone;tag=3a668590-7a41-4176-82cb-090280c27151
CSEQ: 2 BYE
CALL-ID: d256eb0dbf1953b7a8044d597ae2d807
MAX-FORWARDS: 70
VIA: SIP/2.0/TLS 52.114.148.0:5061;branch=z9hG4bK1122222e
REASON: Q.850;cause=79;text=ā€œ96816af3-b3ca-424e-b0bc-0d4e24786e17;Applying remote media information failed. Audio connectivity checks failedā€
CONTACT: sip:api-du-c-uswe2.pstnhub.microsoft.com:443;x-i=96816af3-b3ca-424e-b0bc-0d4e24786e17;x-c=d256eb0dbf1953b7a8044d597ae2d807/d/8/b4fcd0413d0e4850bb92c492b61a0563
CONTENT-LENGTH: 0
USER-AGENT: Microsoft.PSTNHub.SIPProxy v.2021.4.12.3 i.USWE2.1
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY

<— Transmitting SIP response (424 bytes) to TLS:52.114.148.0:6336 —>
SIP/2.0 200 OK
Via: SIP/2.0/TLS 52.114.148.0:5061;rport=6336;received=52.114.148.0;branch=z9hG4bK1122222e
Call-ID: d256eb0dbf1953b7a8044d597ae2d807
From: ā€œLuis Aguirreā€ sip:+59326001001@sip.pstnhub.microsoft.com;user=phone;tag=65765415782345498b24c63d57a3fca3
To: sip:+59322999999@development.contactvox.com;tag=3a668590-7a41-4176-82cb-090280c27151;user=phone
CSeq: 2 BYE
Server: ContactVox
Content-Length: 0

As you can see, the call is stablished, but right after ACK of the INVITE OK, MS Teams send me a BYE with the reason:

"Q.850;cause=79;text=ā€œ96816af3-b3ca-424e-b0bc-0d4e24786e17;Applying remote media information failed. Audio connectivity checks failedā€

Anyone can help me to figure out what the problem is?

Thank you

The PowerShell-Extension ā€œSkypeOnlineConnectorā€ (download here). This in turn needs PowerShell 5.0, plus a special version of Visual C++ 2017 Runtime.

not able to find anything on the download here page.

there is no skypeonlineconnector available on the download here page

please anyone provide a valid link for this

Hi FAKhan,
thanks for your feedback. We’ve updated the blog at
Proof of Concept: Connecting Microsoft Teams via Direct Routing with an Asterisk PBX (ayonik.de)

Issue was, that in the meantime the SkypeOnlineConnector is depreciated by Microsoft and replaced by the MicrosoftTeams PowerSell module. The commands used for both Modules, once it’s installed, are the same.

I do have the same issue…

Hi,
even this is quite an old thread. Maybe for future help:
Might be worth to check, whether something is stuck in a firewall. As to my understanding RTP needs port 10000-20000 to be open towards the Asterisk server.

This is an ancient thread, so the OP will either have solved the problem or given up, but the ports you need to have open in the firewall, and port forwarded in NAT, are those specified in rtp. conf, which could be any valid range.