Custom include in extensions_custom.conf not being called

Hi,
I’m trying to resolve an issue I have with an inbound SIP provider who sets the callerid in an unusual way. I’m planning on ‘fixing’ the callerid in a custom context in extensions_custom.conf and then continue normal processing.

My call flow looks like this by default when a call comes in:

[2022-09-14 11:50:28] VERBOSE[17679][C-000000a4] pbx.c: Executing [[email protected]:1] Set("SIP/sipgate-out-00000168", "GROUP()=OUT_2") in new stack
[2022-09-14 11:50:28] VERBOSE[17679][C-000000a4] pbx.c: Executing [[email protected]:2] Goto("SIP/sipgate-out-00000168", "from-trunk,xxx_myuserid,1") in new stack
[2022-09-14 11:50:28] VERBOSE[17679][C-000000a4] pbx_builtins.c: Goto (from-trunk,xxx_myuserid,1)

So I can see the called context is “from-trunk-sip-sipgate-out” and in that context I see:

[from-trunk-sip-sipgate-out]
include => from-trunk-sip-sipgate-out-custom
exten => _.,1,Set(GROUP()=OUT_2)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

So that means I can use extensions_custom.conf to create a context named “from-trunk-sip-sipgate-out-custom” which I’ve done, and for now added a Noop to check it gets called:

[from-trunk-sip-sipgate-out-custom]
exten => _.,1,NoOp(CUST: from-trunk-sip-sipgate-out-custom by Andy)

But this never appears in the logs, it seems not to switch to this custom context at all, the logs from asterisk are exactly as shown earlier, no additional switch to the custom context. The custom context definitely gets loaded as this is in the logs when a reload/apply is carried out:

[2022-09-14 11:35:41] VERBOSE[15819] pbx.c: Including context 'from-trunk-sip-sipgate-out-custom' in context 'from-trunk-sip-sipgate-out'
[2022-09-14 11:35:41] VERBOSE[15819] pbx.c: Registered extension context 'from-trunk-sip-sipgate-out-custom'; registrar: pbx_config
[2022-09-14 11:35:41] VERBOSE[15819] pbx.c: Added extension '_.' priority 1 to from-trunk-sip-sipgate-out-custom

So why isn’t it getting called? Is it being bypassed because it’s not a more specific match or something?

Please help!
Thanks,
Andy

That’s the way include works in dialplan. If there is already an exten/cid match for the call in from-trunk-sip-sipgate-out-custom then then includes are ignored. I don’t know what you’re doing, but since you have full control over what your own dialplan looks like, you may as well just write it so it doesn’t rely on any include.

It looks strange and hard how you deal with fixing “unusual specific case”, by the other way in your custom context in extensions_custom.conf have been set to any pattern number "exten => ._, ".

One way is to write your dialplan like this:

[from-trunk-sip-sipgate-out]
exten => 15554443333,1,Set(GROUP()=OUT_1)
exten => 15554443333,n,Goto(from-trunk,${EXTEN},1)

exten => _.,1,Set(GROUP()=OUT_2)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

Hi,
Thanks for the replies.

[from-trunk-sip-sipgate-out]
Is generated by freepbx as “sipgate-out” is the trunk name, so the code:

[from-trunk-sip-sipgate-out]
include => from-trunk-sip-sipgate-out-custom
exten => _.,1,Set(GROUP()=OUT_2)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

Is freepbx (set in extensions_additional.conf) so I have no control over that/won’t edit since it’s autogenerated.
Hence why I’m trying to manipulate from-trunk-sip-sipgate-out-custom. Unfortunately I cannot change the context being called here, freepbx won’t honour it (looks like a quirk of how we have a sip trunk from sipgate).

Anyway, so neither of these options were working for me. I take it from Ricardo’s reply since both are matching
exten => ._,
Then that’s the problem, since extensions_additional.conf comes first it’s preferred and so ignores my custom?

What I’ve done instead is added to extensions_override_freepbx.conf an override for the function to do what I need.
For anyone in the future that has sipgate in the UK and find it’s not seeing their multiple DID’s at all, then you can do this code:

[from-trunk-sip-sipgate-out]
exten => _.,1,Set(GROUP()=OUT_2)
exten => _.,n,Noop(override from-trunk-sip-sipgate-out by Andy)
exten => _.,n,SET(IN_DID=${SIP_HEADER(From)})
exten => _.,n,SET(IN_DID=${CUT(IN_DID," ",1)})
exten => _.,n,Goto(from-trunk,${IN_DID},1)

Because sipgate send the inbound DID in an unusual way, see the sip call trace:

From: "01642XXXXXX" <sip:[email protected]>;tag=as4d3dcc55

You see, the DID is in the quotes in the FROM field (01642X), the callerid is the sip:079. So to get your DID inbound numbers to match you need the fix I’ve done.

1 Like

I see your requirement now. You need to edit the trunk settings to use your own context:

Then in extensions_custom.conf create the dialplan you want to use following this format:

[from-pstn-andyb2000]
exten => _.,1,NoOp(CUST: from-pstn-andyb2000 by Andy)
; add whatever you need here
exten => _.,n,Goto(from-trunk,${EXTEN},1)