Customize outgoing caller name and caller ID by number dialed

I am using FreePBX 15.0.16.44/Asterisk 16.9.0

Should the following work in this release and can anyone tell me what I am doing wrong to make this happen? TIA

I have a need to change the CALLERID(NUM) for a few dialed numbers otherwise what I have set for the individual extensions I would like to use.

For example I have ext 101 and the caller id could be 6095551212 for the following numbers dialed I would like those changed accordingly:
dialed number cnam(number)
2125551212 6095551300
2125559999 6095551400
I tried to use the following example in extensions_custom to make the change but it didn’t work. It didn’t change the number stored in the “outbound CID”

; Customization: Add a trunk predial hook to examine the outbound caller ID number and set the
; outbound caller ID name based on the number (a workaround for a foreign PBX that cannot set the caller ID name string)
[macro-dialout-trunk-predial-hook]
; add log output to show outgoing caller ID information before any changes are made
; note: don’t comment out the first line without modifying the new actual first line of code to be sequence number 1
exten => s,1,NoOp(CUSTOM: calleridall is ${CALLERID(all)})
exten => s,n,NoOp(CUSTOM: calleridnumber is ${CALLERID(number)})
; test number case for debugging: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to 555-555-1212 (remove comments to enable)
;;exten => s,n,ExecIf($["${CALLERID(number)}" = “+15555551212”]?NoOp(CUSTOM: Setting Caller ID override for source ${CALLERID(number)}))
;;exten => s,n,ExecIf($["${CALLERID(number)}" = “+15555551212”]?Set(CALLERID(all)=“Test Number” <5555551212>))
; branch office location 1: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to 519-123-4567
exten => s,n,ExecIf($["${CALLERID(number)}" = “+12125551212”]?NoOp(CUSTOM: Setting Caller ID override for source ${CALLERID(number)}))
exten => s,n,ExecIf($["${CALLERID(number)}" = “+12125551212”]?Set(CALLERID(all)=“Branch Office” <6095551300>))
exten => s,n,ExecIf($["${CALLERID(number)}" = “+12125559999”]?NoOp(CUSTOM: Setting Caller ID override for source ${CALLERID(number)}))
exten => s,n,ExecIf($["${CALLERID(number)}" = “+12125559999”]?Set(CALLERID(all)=“Branch Office” <6095551400>))
; default case for the main office: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to nothing to be the main office caller ID name and number
exten => s,n,ExecIf($["${CALLERID(number)}" = “”]?Set(CALLERID(all)=“Main Office” <6141234567>))
; exit back
exten => s,n,MacroExit()
~

You should not need any custom code for this. Just set up an Outbound Route matching the special destination number (ahead of the regular route), specify the desired Route CID and check Override Extension.

Thanks very much. I will try it out.

Thanks very much. I tried it and it works perfectly. Thanks very much for your help and an answer on how to do this. Very much appreciated.

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