How to add prefix to incoming calls

It’s the upper management decision. Dead end there.

accept their stubborness, it is often real in ‘the world’ (as old fashioned as they are) , allow all dial patterns but in the middle between outbound routes and trunks and inbound calls, normalize both in and out to be fully e164 compliant, (with a + or not , 10 or 11 or 7 by your locale accept centrex gracefully but mask it in your CallerID(num))

My question is why the system ignore the code in extensions_custom.conf?? the extensions.conf includes [from-pstn-custom] context. Why is it ignoring it?

[from-pstn]
include => from-pstn-custom ; create this context in extensions_custom.conf to include customizations

again, does the incoming call go to that context, just post a log to prove it.

I don’t see “from-pstn-custom” in the log. That is the trouble. Why it doesn’t go to that context.

cos you didn’t send the inbound route there perhaps ?

My sip trunk is set to context=from-pstn. If I set it to context=from-pstn-custom, the incoming call won’t get through. The system just doesn’t know where [from-pstn-custom] is.

Then you need to fix that , there is a wiki linked at the top of this page.

The context from-pstn-custom doesn’t exist until you create it. BUT, you are strongly discouraged from using this context. If you want to preprocess inbound calls use your own context like in this post: Context for scripts (incoming calls)

Please try the following. Add this to extensions_custom.conf :

[from-pstn-prefix-cid]
exten => _.,1,NoOp(Entering user defined context from-pstn-prefix-cid in extensions_custom.conf)
exten => _.,n,set(CALLERID(num) = 9${CALLERID(num)})
exten => _.,n,Goto(from-pstn,${EXTEN},1)

Change the Context for your incoming trunk from from-pstn to from-pstn-prefix-cid and test.
If the call fails, paste the Asterisk log for the call at pastebin.freepbx.org and post the link here.

Added the code and changed the context in the SIP trunk. The leading digit “9” is still not showing from the incoming calls. Here is the log.

https://pastebin.freepbx.org/view/f8c25c7f

Sorry, it appears that the spaces in set(CALLERID(num) ... may have caused trouble.
But I also didn’t know that your provider is sending E.164 format.
If you want to show 914086346448 then try

[from-pstn-prefix-cid]
exten => _.,1,NoOp(Entering user defined context from-pstn-prefix-cid in extensions_custom.conf)
exten => _.,n,set(CALLERID(num)=9${CALLERID(num):1})
exten => _.,n,Goto(from-pstn,${EXTEN},1)

or if you want to show 94086346448 then try

[from-pstn-prefix-cid]
exten => _.,1,NoOp(Entering user defined context from-pstn-prefix-cid in extensions_custom.conf)
exten => _.,n,set(CALLERID(num)=9${CALLERID(num):2})
exten => _.,n,Goto(from-pstn,${EXTEN},1)

If no luck, please paste another log.

That works perfectly. Very appreciated !!!

May I ask why I shouldn’t use it? Looking at the documentation in extension.conf:

;-------------------------------------------------------------------------------
; from-pstn:
;
; Entry context for calls from the outside world to hit FreePBX
[from-pstn]
include => from-pstn-custom             ; create this context in extensions_custom.conf to include customizations

because it would be ‘re-entrant’, if you add the callerid in your custom context then send it back to from-trunk (effectively the same as from-pstn) , which would then catch your from-pstn-custom and round and round you go.

Due to the way includes are arranged, every line you put in from-pstn-custom overrides a line generated by FeeePBX.

Well, I’m using it exactly as documented to remove ‘+’ sign at CID and DID - and it works just fine:

[from-pstn-custom]
exten => _+.,1,GotoIf($["${CALLERID(num):0:1}" != "+"]?noplusatstart)
exten => _+.,n,Set(CALLERID(num)=${CALLERID(num):1})
exten => _+.,n(noplusatstart),Noop()
exten => _+.,n,Goto(${EXTEN:1},1) ; remove + from DID

If you shouldn’t use it, it should be removed in the documentation in the file.

Point taken: https://issues.freepbx.org/browse/FREEPBX-21952

Thanks! Strange kind of inclusion of customizations by overriding existing code. What was the original idea of doing it like that?

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