Outbound CID on Intra Company Route

For many years we have been sending the User extension number to cell phones using follow me. This has been working great as follow-me calls to cell phones show the user extension. Carriers are now treating 4-digit CID as SPAM.

Each of our Users’ extensions also has a DID number which is set as their Outbound CID. The Outbound Route has it’s CID (Main Number) which is used for typical outbound calls.

Each Users’ Cell phone has it’s own Intra-Company route, which broadcasts the User’s extension as the CID. I would like to modify the macro-user-callerid and override it in macro-user-callerid-custom so that the User’s Outbound CID is used in place of the extension number, ONLY on Intra-Company route, not on internal or other routes. Honestly, I’m not savy enough to understand this macro. I’m looking for advice on howto change this code.

[macro-user-callerid]
include => macro-user-callerid-custom
exten => s,1,Set(TOUCH_MONITOR=${UNIQUEID})
exten => s,n,Set(AMPUSER=${IF($["${AMPUSER}" = ""]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CUT(CHANNEL,@,2):5:5}"="queue" | ${LEN(${AMPUSERCIDNAME})}]?report)
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,GotoIf($["${AMPUSER}" = "none"]?limit)
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["${AMPUSERCIDNAME:1:2}" = ""]?report)
exten => s,n,Set(AMPUSERCID=${IF($["${ARG2}" != "EXTERNAL" & "${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})})
exten => s,n,Set(__DIAL_OPTIONS=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/dialopts)}" = "1"]?${DB_RESULT}:${DIAL_OPTIONS})})
exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" <${AMPUSERCID}>)
exten => s,n,GotoIf($["${ARG1}"="LIMIT" & ${LEN(${AMPUSER})} & "${DB(AMPUSER/${AMPUSER}/concurrency_limit)}">"0" & "${GROUP_COUNT(${AMPUSER}@concurrency_limit)}">="${DB(AMPUSER/${AMPUSER}/concurrency_limit)}"]?limit)
exten => s,n,ExecIf($["${ARG1}"="LIMIT" & ${LEN(${AMPUSER})}]?Set(GROUP(concurrency_limit)=${AMPUSER}))
exten => s,n,GosubIf($[${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)})} & "${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)}" != "never"]?sub-ccss,s,1(${MACRO_CONTEXT},${CALLERID(dnid)}))
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != ""]?Set(CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)}))
exten => s,n(report),GotoIf($[ "${ARG1}" = "SKIPTTL" | "${ARG1}" = "LIMIT" ]?continue)
exten => s,n(report2),Set(__TTL=${IF($["foo${TTL}" = "foo"]?64:$[ ${TTL} - 1 ])})
exten => s,n,GotoIf($[ ${TTL} > 0 ]?continue)
exten => s,n,Wait(${RINGTIMER})
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(im-sorry&an-error-has-occured&with&call-forwarding)
exten => s,n,Macro(hangupcall,)
exten => s,n(limit),Answer
exten => s,n,Wait(1)
exten => s,n,Playback(beep&im-sorry&your&simul-call-limit-reached&goodbye)
exten => s,n,Macro(hangupcall,)
exten => s,n,Congestion(20)
exten => s,n(continue),Set(CALLERID(number)=${CALLERID(number):0:40})
exten => s,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => s,n,Set(CDR(cnum)=${CALLERID(num)})
exten => s,n,Set(CDR(cnam)=${CALLERID(name)})
exten => s,n,Set(CHANNEL(language)=${MASTER_CHANNEL(CHANNEL(language))})

exten => h,1,Macro(hangupcall,)

;--== end of [macro-user-callerid] ==--;

I’m not sure I understand the question. If you’re sending local calls across intracompany routes to another PBX when then go to the PSTN, you might be able to adapt this technique: What is the best way to connect multiple FreePBX together?

Lorne,

Thanks for your input. Let me try to explain more clearly.

Typically an Intra-Company route sends the extension number as the CID. I want to modify the macro so that the extension’s “Outbound CID” gets sent, not the extension number itself. Does that explain it?

Sounds like you just need to disable the intra company option for the route.

If it’s acceptable for an intracompany call to show the outbound CID on both desk phones and mobile, then just turning off the intracompany option is adequate.

But if you want the deskphone user to see a 4-digit extension number but show the full number when forwarded to mobile, you’ll need to do something similar to what @lgaetz recommended. If the intracompany trunk is SIP (not IAX), you will need to modify the code to use custom headers.

Or, if there is a simple transformation between extension number and full number, your macro could do that.

Thanks Stewart and Lorne! :+1:

That is exactly what I needed. I will add it to extensions_custom.conf and modify accordingly. I’ll let you know how it works out.

This is what I finally came up with. Seems to work as intended.

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf)

; determine if call is intracompany or not
exten => s,n,Noop(INTRACOMPANYROUTE: ${INTRACOMPANYROUTE})
exten => s,n,GotoIf($["${INTRACOMPANYROUTE}"="YES"]?intra:end)
exten => s,n(intra),Set(AMPUSER=${IF($["${AMPUSER}" = ""]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,Noop(AMPUSER: ${AMPUSER})
exten => s,n,Set(KEEPCID="FALSE")
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n,goto(end)

exten => s,n(end),MacroExit

;  --==> end of context [macro-dialout-trunk-predial-hook] <==-

OK, it didn’t work as intended but I think this does:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf)
; Remove Headers - Carrier does not like "Diversion" and "Alert-Info" which are passed on Ring Group Follow-Me Extensions apended with a # ex:5001#
exten => s,n,SIPRemoveHeader(Alert-Info:)
exten => s,n,SIPRemoveHeader(Diversion:)
exten => s,n,Noop(AMPUSER: ${AMPUSER})

; determine if call is intracompany or not
exten => s,n,Noop(INTRACOMPANYROUTE: ${INTRACOMPANYROUTE})
exten => s,n,GotoIf($["${INTRACOMPANYROUTE}"="YES"]?intra:end)

exten => s,n(intra),Noop(This is an Intra-Company Route)
exten => s,n,GotoIf($["foo${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)}" = "foo"]?keepcid:nokeepcid)

; External Caller - Don't set AMPUSER
exten => s,n(keepcid),Set(KEEPCID=TRUE)
exten => s,n,goto(endif)

;Internal Caller - Set AMPUSER
exten => s,n(nokeepcid),Set(KEEPCID=FALSE)
exten => s,n,Set(AMPUSER=${IF($["${AMPUSER}" = ""]?${CALLERID(number)}:${AMPUSER})})

exten => s,n(endif),Noop(AMPUSER: ${AMPUSER})
exten => s,n,Noop(KEEPCID: ${KEEPCID})
exten => s,n,Noop(OUTKEEPCID: ${OUTKEEPCID_${ARG1}})

exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n,goto(end)

exten => s,n(end),MacroExit

;  --==> end of context [macro-dialout-trunk-predial-hook] <==--

I’m still puzzled with what is going on here. The ONLY thing the Intra-Company toggle does on an outbound route is to send the call out with the CID of the extension number instead of the external CID. If you don’t want the extension number, then you should only need to toggle intra-company off.

I believe that I understand what the OP wants, but don’t understand how he is trying to accomplish it.

If an intracompany call is made to an extension that has follow me enabled to an external number, he wants the extension number displayed on the deskphone and the Outbound CallerID sent to the external number, i.e. both may be required on the same call.

In the example that you linked, an IAX trunk was used, set up specially to transmit both caller ID values. At the receiving end, the custom logic selects the proper one, based on where the call is going. But in the OP’s code, he seems to be using a database but I don’t understand how it gets populated.

If there is an algorithmic mapping, e.g. extension 456 has caller ID 1 212 555 7456, then only one value need be sent on the trunk.

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