Incoming calls don't work, why?

ITSP shouldn’t send calls to s extension, why they aren’t transmitting the dialed number, shouldn’t be 0427714121 like “TO” field ?!

No, I use an other number for incoming calls. Maybe it’s my voip provider who makes something in our IPBX.
But there is something strange, if I have two or more numbers for incoming calls, I must to find a way to recognize each of them and redirect each numbers to the good extensions.

As say @gjoseph If I can get the data from the incoming INVITE, I’ll solve this issue. I think…

@gjoseph, I have a question. If I have two number for incoming call. By example:

  • 028992018 and 044751412

How to redirect each number to a extension ?

If someone call the 028992018, it’s the extension 102 who ring and if it’s the 044751412 we have the extension 103 who ring.

This is what I have in my dialplan:

[from-belgium-voip]
exten => s,1,NoOp(### Incoming call from outside to 028992018 ###)
same => n,Dial(PJSIP/102,20)
same => n,Dial(PJSIP/103,20)
same => n,VoiceMail(102)
same => n,Hangup()

How identify each incoming number to redirect it to the right extension ?

The incoming numbers are extensions, in Asterisk terms. You can go from one extension to another using GoTo.

However, it is possible that the numbers are not being presented as incoming numbers.

I can’t remember if you were the most recent person to ask about “not found in context” messages, but if you are, the number is being presented in a way that Asterisk will directly interpret as an extension.

Incidentally, people tend to confuse Asterisk devices with extensions. There is no need to use GoTo, if you really mean device 200; just dial it.

Do a packet capture and see if there’s a header you can extract the called number from using the PJSIP_HEADER function, It’s likely in the To header.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_PJSIP_HEADER

exten => s,1,Set(Destination=${PJSIP_HEADER(read,To)})
 same => n,Set(Destination=${CUT(Destination,@,1)})
 same => n,NoOP(Destination is ${Destination)
[real-context]
exten = 028992018,1,Dial(PJSIP/102,20)
exten = 044751412,1,Dial(PJSIP/103,20)

[from-belgium-voip]
; Parse the number out of the To header
exten = s,1,Set(ACTUAL_NUMBER=$["${PJSIP_HEADER(read,"To")}" =~ "<sip:([0-9]+)@"])
same =  n,GoTo(real-context,${ACTUAL_NUMBER},1)

Is it the register of my provider ?

No. It is a regular expression (for pattern matching).

However the advice assumes that you aren’t being sent the information in the request URI.

Yeah, it’s a regular expression pattern match on the To header. It pulls the number out and assigns it to ACTUAL_NUMBER

@david551 From this particular ITSP he’s getting ‘s’ as the user in the request URI and the actual destination as the user portion of the To URI. Not technically correct but we’ve seen this case once or twice.

Hi, On my asterisk server my provider give one to outgoing call 0227714121 and 1 number for incomcing call
028992018 at Belgium Voip. But when I try your script, this is don’t work. But When I put in the context [real-context] the number who is show to person I call (0227714121) , now this is work.

Why when I compose the 028992018, it’s this number 0227714121 who is show in the ACTUAL_NUMBER ?

@gjoseph, Do you have an explanation ?

Hi @everyone,

I ask to my provider Belgium Voip why I have this issue when someone call the inbound number and they tell me it’s normal that I have this issue because my number inbound is not my sip account. They just use the number in my sip account (sip:028992018@belgium-voip.com) but this is not meant it’s my number.

By example:
Account sip:028992018@belgium-voip.com --> Number 027898547
Account sip:0289920181@belgium-voip.com --> Number 027894562
Account sip:0289920182@belgium-voip.com --> Number 028524578

So they have change the parameter “Send called number as request URI” to Yes
And now when I put this is in my extensions.conf file all work very well:

[belgium-voip-provider]
exten => _028992018,1,NoOp(### Incoming call from outside to 028992018 ###)
 same => n,Ringing()
 same => n,Dial(PJSIP/104,20)
 same => n,Dial(PJSIP/101,20)
 same => n,VoiceMail(101)
 same => n,Hangup()