I’ve been looking a while now, for a proper pjsip-configuration for Asterisk that works with Skype. I found almost nothing but a shitload of dead ends. Either there was 484 Address Incomplete messages, 404 Not found or 403 Forbidden messages and nothing was leading me right. It turned out, not very quickly though, that the 403 Forbidden message was a thing about credits on the account that just had to be refilled.

Besides of this, most of the documentations covers just SIP (sip.conf) and that’s it. So here we go, with a default quick configuration for Skype, with Asterisk. The configuration is based on endpoints, so there’s nothing advanced with it. Just very basic.

First of all. You need to get yourself a phone number. This could be done via Skype Manager (as of july 2019, you may want to go via https://manager.skype.com/my/dashboard – however, links tend to die very fast on internet so over a few years this will probably also mismatch). Try to find your way to the ”Skype Connect” section (as of july 2019, I clicked via the allocation links – but I think you have to think a bit of yourself too). Configure what you need here and make sure you have credits added to the ”Outgoing calls” section!! Like the part below.

Next part is about configuring channels. So click on the channel-part and then jump the ”Authentication settings”. At this page, you will need to put the username and password into your pjsip.conf, with the sip address. An important note to remember here is that I’ve configured another port for my Asterisk server, rather than 5060, that is often very highliy scanned for flaws. However, this configuration should work fine even with this different setup.

Next up – edit your pjsip.conf – I have a very compact configuration myself together with another peers, to keep the rows simple to edit. With the other base peers I’ve also managed to confirm that another SIP peer like Skype actually works. I’m in Sweden, so I have a swedish number. In this case, we’ll pretend I’ve got a number in Helsingborg (042). Together with the username from Skype, the configuration is set like below.

 server_uri=sip:[email protected]
 client_uri=sip:[email protected]
 ;Is the contact_user here really necessary?
 contact=sip:[email protected]

And since I actually have a transport layer in there, I should probably show an example of that one too.


So. What now? I’m done? No. There’s more to think of. How to make calls and how to receive them. I actually have an [inbound]-context where everything happens (which should be changed later on). However, to receive calls in Asterisk, you’ll put an extension that matches your phone number when Skype sends it to you. Like this:

exten => 46421234567,1,Answer
exten => 46421234567,n,NoOp(${CALLERID})
exten => 46421234567,n,Wait(1)
exten => 46421234567,n,Set(CALLFILENAME=${EXTEN}-${CALLERID(num)}-${STRFTIME(${EPOCH},,%y%m%d%H%M%S)})
exten => 46421234567,n,Monitor(wav,${CALLFILENAME})
exten => 46421234567,n,BackGround(PlayBeforeCalling)
exten => 46421234567,n,VoiceMail(INTERNAL_EXTENSION_VOICEMAIL_ID,u)
exten => 46421234567,n,Hangup

As you can see above, there’s a bit of mumbo jumbo. This is used for a few reasons. I’d like to monitor all in- and outbound calls and record them as wavefiles. That’s why they are tagged with extension, caller id and a timestamp. However, it is in Sweden required to tell callers that they are recorded, so that’s what the PlayBeforeCalling is made for.

That was the inbound part. The outbound part is as easy as the inbound set up. It is however configured in another context. For the outgoing calls. As I use another phone number as the default exit point, I’ve added a prefix to the Skype number. The Skype number is also limited to Sweden and has to be in the format of E.123. This is not necessary, but if you want to use a Skype number ”as is” you also have to include the country code in the mentioned format (i.e. +46421234567). I solved this by only using the number in my own country. The rule for this number is that I have to hit ”90” before the real number. So if I want to dial 042654321 I use 90042654321 to reach out). Doing this generic with only ”+” before the number is way too much job and would look like 904642654321. There will be in short too much number to remember to not forget… So here is the outbound configuration for Skype.

To be real safe, I also set up the caller id number as my phone number. And of course – I’m starting to monitor outbound numbers also. Like this:

 exten => _90X.,1,Set(CALLFILENAME=${EXTEN}-${CALLERID(num)}-${STRFTIME(${EPOCH},,%y%m%d%H%M)})
 exten => _90X.,n,Monitor(wav,${CALLFILENAME})
 exten => _90X.,n,Set(CALLERID(num)[email protected])
 exten => _90X.,n,Dial(PJSIP/+46${EXTEN:3}@skype-0421234567,,rwWkK)
 exten => _90X.,n,Hangup

I think this is it. There’s a lot more configuration so please tell if something is missing or failing. Unfortunately there’s to few PJSIP-configuration examples out there…

av Tornevall

Fotograf, musiker, filmare. Estetikens alla nyanser i ett, kombinerat med humor och ett förflutet inom vård- nöjes- och programmeringsbranscher.