FreePBX | Register | Issues | Wiki | Portal | Support

Getting the DID number from a CallCentric SIP trunk for FreePBX


(Dragan) #1

Getting the DID number in the TO field.

Hello, I have the next problem
I use FreePBX 13.0.192.16 and I’m connected to the ISP provider by sip trank. Through the same sip trank ISP send 3 numbers.The main number is working with me, but I have a problem with the other two. ISP sends me the DID in the “to” field. What I found as a solution in various tutorials is to edit:
/etc/asterisk/extensions_custom.conf
To add a line:
[custom-get-did-from-sip]
exten => _X!,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
or:
[custom-get-did-from-sip]
exten => _.,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
I tried both examples
while changing in the Trank setting Incoming/USER Details context=custom-get-did-from-sip
After this, I make the route for the corresponding DID, but when I call that second number the calls always end up on the main…which seems to me that the asterisk can not read the DID that is in the header in the TO field.
What I think is the problem that my function will NOT cut off the DID correctly.
From the provider I get the identical TO field in this one:
To:"L22 Somename doo"tel:+38757xxxxxx

If someone has an idea where the problem would be, he would be very grateful :slight_smile:


(Tom Ray) #2

Use from-pstn-toheader as the context and test again.


(Dragan) #3

I changed:
context=from-pstn-toheader
same :confused:


(Tom Ray) #4

Show the output.


(Dragan) #5

<— SIP read from UDP:10.252.64.110:5060 —>
ACK sip:+387572016xx@10.221.241.78:5060 SIP/2.0
Via: SIP/2.0/UDP 10.252.64.110:5060;branch=z9hG4bKsuvl1tt7ssgaagoosgz1qsbpuT33493;received=10.252.64.110
Call-ID: asbcBW1452384082612181137017059@10.10.10.4
From: sip:057931931@10.252.64.110;user=phone;tag=sbc04022002029015-1545832358408-
To: "L22 Majnex doo"tel:+387572270xx;tag=as7485f4d7
CSeq: 895807749 ACK
Max-Forwards: 70
Content-Length: 0

+387572016xx is the main number
+387572270xx is the other with which I have a problem
057931931 I’m trying to get a call from him (I’m calling a number +387572270xx) and he always takes me to the first number +387572016xx


(Tom Ray) #6

I mean the entire call. As well it needs to be formatted more properly so it doesn’t try to format HTML when you paste it.


(Tom Ray) #8

No, I meant with the sip debug on like you posted before with the ACK message but you only posted one message in the call. I want the debug from the start of the call.

sip set debug on then make call.


#9

I believe that the context is not being executed because the Peer Details are conflicting. Set the context there, too. (Ideally, you should put all settings there and leave User Details blank, except for Register String.)

Also, to ensure that special characters aren’t garbled, paste your log at pastebin.freepbx.org and just post a link here.


(Dragan) #10

Here’s a debug, I think I’ve captured everything from the beginning of the call to the end, as he suggested @Stewart1 :slight_smile:
Debug
peer Outgoing:
username=+38757xxxxxx@mtel.ba
type=peer
trustrpid=yes
sendrpid=yes
secret=xxxxxxx
qualify=yes
nat=auto
insecure=port,invite
host=mtel.ba
fromuser=+38757xxxxx
outboundproxy=10.252.64.110
fromdomain=mtel.ba
disallow=all
allow=alaw&ulaw&gsm&g729
context=from-trunk
Incoming/USER Details:
username=+38757xxxxxx@mtel.ba
type=user
fromuser=+38757xxxxxx
insecure=port,invite
dtmfmode=auto
disallow=all
context=custom-get-did-from-sip
allow=ulaw
Register String:
+38757201xxx:xxxxxxx+38757201xxx@mtel.ba@mtel.ba/+38757201xxx~3600
/etc/asterisk/extensions_custom.conf:
[custom-get-did-from-sip]
exten => _X!,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
+38757201xxx is the main number
+38757227yyy is the other with which I have a problem

what can I try?


(Tom Ray) #11

Like @Stewart1 said you just need the OUTGOING section to have the peer details with the only thing in the Incoming section being the name and register string.

Neither one of these show the context being updated to be from-pstn-toheader, however, they are sending a TEL URI instead of a SIP URI which means that context probably won’t work due to the way they are presenting the To Header.

To: “L22 Majnex doo”<tel:+38757227097>

Which means this unusable since the format doesn’t have a @ to match against.

exten => _.,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)

This needs to be updated to CUT() the tel formatted To Header.

Try this:

exten => _.,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),:,2),>,1)},1)


(Dragan) #12

Thanks for your reply @BlazeStudios,as you wrote:

/etc/asterisk/extensions_custom.conf:
> [custom-get-did-from-sip]
> exten => _.,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),:,2),>,1)},1)
peer Outgoing: remained unchanged
username=+38757201xxx@mtel.ba
type=peer
trustrpid=yes
sendrpid=yes
secret=xxxxxxx
qualify=yes
nat=auto
insecure=port,invite
host=mtel.ba
fromuser=+38757201xxx
outboundproxy=10.252.64.110
fromdomain=mtel.ba
disallow=all
allow=alaw&ulaw&gsm&g729
context=from-trunk
Incoming/USER Details:
USER Context:+38757201xxx
Register String:+38757201xxx:xxxxxxxx:+38757201xxx@mtel.ba@mtel.ba/+38757201xxx~3600
(I tried it with :context=custom-get-did-from-sip and and without him)
I have inbound route +38757227097 Any BB [Extensions: 204 Butik]
But again when I call with 057931xxx DID +38757227yyy it only rings Extensions which is associated with the main number +38757201xxx
Here’s a debug:
debug2
@BlazeStudios I hope I did what you suggested in the last post :confused:


(Tom Ray) #13

You need to update the context setting. It needs to be context=custom-get-did-from-sip in order to use your custom context. You still have it pointing to “from-trunk”


(Dragan) #14

Finally works! thank you for your help, you were very quick and successful! @BlazeStudios and @Stewart1
When the topic is already open I tried to use one extension to use outbound CID +38757227097 or whole outbound route (second number) but he goes back through the main number again :confused: This is not a problem for me now, but I’m thinking again about how I can make calls with another number +38757227xxx


#15

In your trunk outbound settings, try changing
sendrpid=yes
to
sendrpid=pai

If no luck, check m:tel documentation for how to format the outbound caller ID (which header, whether they want the + or country code, etc.), or contact them for help. Providers have different ways of doing this and it won’t work unless you get all the details correct.


(Dragan) #16

He solved the problem, thank you! :smiley:


(system) #17

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.