How to add prefix to incoming calls


#8

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


#9

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))


#10

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


#11

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


#12

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


#13

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


#14

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.


#15

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


(Lorne Gaetz) #16

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)


#17

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.


#18

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


#19

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.


#20

That works perfectly. Very appreciated !!!


(Dirk2358) #21

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

#22

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.


(Lorne Gaetz) #23

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


(Dirk2358) #24

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.


(Lorne Gaetz) #25

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


(Dirk2358) #26

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


(system) closed #27

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