Override a core context

Hello,

I would like to override macro-outbound-callerid so i can check for assigned variable and set __KEEPCID=TRUE if condition is true.
As i read in documentation, i should add the override in /etc/asterisk/extensions_override_freepbx.conf
It works as expected when i add it - the main purpose is keep original CID if caller is comming from PSTN and the call flow is a forward to external number:

[macro-outbound-callerid]
include => macro-outbound-callerid-custom
exten => s,1,Noop(${REALCALLERIDNUM})
; Addring logic to keep cid if forwarding
exten => s,n,NoOp(From PSTN=${FROM_PSTN}}
exten => s,n,ExecIf($["${FROM_PSTN}" != “”]?Set(KEEPCID=TRUE))
; eob
exten => s,n,Noop(${KEEPCID})
exten => s,n,Noop(${OUTKEEPCID
${ARG1}})
exten => s,n,ExecIf($["${CALLINGNAMEPRES_SV}" != “”]?Set(CALLERPRES(name-pres)=${CALLINGNAMEPRES_SV}))
exten => s,n,ExecIf($["${CALLINGNUMPRES_SV}" != “”]?Set(CALLERPRES(num-pres)=${CALLINGNUMPRES_SV}))
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" =""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n,ExecIf($[$["${CIDMASQUERADING}" = “TRUE”] & $[$["${AMPUSER}" = “”] | $["${AMPUSER}" = “${DB(AMPUSER/${FROMEXTEN}$
exten => s,n(start),GotoIf($[ $[”${REALCALLERIDNUM}" = “”] | $["${KEEPCID}" != “TRUE”] | $["${OUTKEEPCID
${ARG1}}" = “on”] ]?$
exten => s,n,Set(USEROUTCID=${CALLERID(name)} <${REALCALLERIDNUM}>)
exten => s,n,GotoIf($["${CIDMASQUERADING}" = “TRUE”]?normcid)
exten => s,n,GotoIf($["${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = “” & “${DB(DEVICE/${REALCALLERIDNUM}/user)}” = “”]?bypass)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${AMPUSER}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($["${EMERGENCYROUTE:1:2}" = “” | “${EMERGENCYCID:1:2}” = “”]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n,GotoIf($["${CALLERID(name)}" = “”]?cnum)
exten => s,n,Set(CDR(outbound_cnam)=${CALLERID(name)})
exten => s,n(cnum),Set(CDR(outbound_cnum)=${CALLERID(num)})
exten => s,n(exit),MacroExit()
exten => s,n(trunkcid),ExecIf($[${LEN(${TRUNKOUTCID})} != 0]?Set(CALLERID(all)=${TRUNKOUTCID}))
exten => s,n(usercid),ExecIf($[${LEN(${USEROUTCID})} != 0]?Set(CALLERID(all)=${USEROUTCID}))
exten => s,n,ExecIf($[${LEN(${TRUNKCIDOVERRIDE})} != 0 | ${LEN(${FORCEDOUTCID_${ARG1}})} != 0]?Set(CALLERID(all)=${IF($[${LEN$
exten => s,n(hidecid),ExecIf($["${CALLERID(name)}"=“hidden”]?Set(CALLERPRES(name-pres)=prohib_passed_screen))
exten => s,n,ExecIf($["${CALLERID(name)}"=“hidden”]?Set(CALLERPRES(num-pres)=prohib_passed_screen))
exten => s,n,Set(CDR(outbound_cnum)=${CALLERID(num)})
exten => s,n,Set(CDR(outbound_cnam)=${CALLERID(name)})

;–== end of [macro-outbound-callerid] ==–;

All ok but when i reload dialplan it shows WARNINGS:
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Context ‘macro-outbound-callerid-custom’ already included in ‘macro-outbound
-callerid’ context on include at line 5457 of /etc/asterisk/extensions_additional.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 1 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5458 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 2 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5459 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 3 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5460 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 4 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5461 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 5 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5462 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 6 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5463 of /etc/asterisk/extensions_additi
onal.conf
[2019-10-04 18:04:18] WARNING[26512] pbx.c: Unable to register extension ‘s’ priority 7 in ‘macro-outbound-callerid’, already i
n use
[2019-10-04 18:04:18] WARNING[26512] pbx_config.c: Unable to register extension at line 5464 of /etc/asterisk/extensions_additi
onal.conf

How this could be overriden without error in dial plan ?

There is no error - the warning is telling you that you have overridden the extensions_additional.conf code. The warnings are telling you that there might be an error since you are trying to re-add all of this code and there could be an inadvertent include error.

Please explain what you are trying to do. By default, a call from an external number, forwarded to an external number, preserves the caller ID of the original caller. No custom dial plan is needed.

If that’s not working properly on your system (you’re seeing the company number instead), this might be forced by the Outbound Route or the Trunk settings. It’s possible that your trunking provider doesn’t permit you to send a number that’s not yours, or requires a special agreement to enable that feature.

Other common sources of this trouble are sending the caller ID in the wrong header or the wrong format (compared to what the provider expects), or failing to include a Diversion or other special header that the provider requires.

cynjut, thanks for the reply. I thought the warnings indicate serious error but it seems to be working.

Stewart1, yes trunk have the company CID set. This is needed in case an internal extension is dialing out through this trunk. However the forwarded call also keeps the trunk CID. So i have to make it distinguish if call comes from PSTN or from internal extension. If from PSTN and end of the call is another external number then keep caller CID.

I have no limitations with my provider so i can send INVITE from any CID, just need to tell asterisk what CID should it use in the different call flows.

@miro_igov Please read the Wiki and the Tooltips available in the GUI.

From Wiki: Log In - Documentation

2019-10-09%2011_41_15-Window

From Tooltip in GUI:

So far there have been multiple people saying what you are trying to do is unnecessary and they are right. When a call hits the Inbound Routes, they are tagged as coming from the PSTN already. There is also a variable set ${KEEPCID} that is set in anything that could forward the call out to the PSTN (CF, FM, etc). All of that is looked at already.

Have you read up on any of this and actually tried it?

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