You are on page 1of 2

Customize outgoing caller name and caller ID

Caller ID reference material


good background page: "Asterisk CallerID Perfected: CallerID Superfecta 2.0", http://nerdvittles.com/?p=609
"The problem is that most telephone providers deliver only a CallerID number when sending calls. Your DID service provider is
responsible for looking up the incoming number in their directory and supplying a matching name. Simply stated, CallerID
numbers are pushed to recipients, but CallerID names must be pulled from in-house databases."
notes from Asterisk source code comments:
Caller ID names are currently 8 bit characters, propably ISO8859-1, depending on what your channel drivers handle
IAX2 and SIP caller ID names are UTF8
On ISDN Caller ID names are 7 bit, Almost ASCII (see http://www.zytrax.com/tech/ia5.html)
note: Asterisk does not currently support SIP utf8 caller ID names or caller ID's
IETF definition of PSTN CNAM data (from http://tools.ietf.org/html/draft-ietf-enum-cnam-03)
"Calling Name data is a string of up to 15 ASCII [9] characters of information associated with a specific calling party number [10]
[11] [12] [13] [14]. In the Public Switched Telephone Network (PSTN) this data is sent by the originating network only at the
specific request of the terminating network via a SS7 Transaction Capabilities"

Set outgoing caller ID name and number based on source extension or


outgoing trunk
By default, FreePBX can set outgoing caller name and caller ID either at the extension level or at the trunk level (setting this at the trunk level is
less work than doing so for all the extensions individually). This is the usual way to set outgoing caller ID.

Applications > Extensions


(select extension)
Extension Options > Outbound CID: (enter caller ID name and number string)

or

Connectivity > Trunks


(select trunk)
General Settings
Outbound CallerID: (enter caller ID name and number string)
CID Options: Force Trunk CID

Set outgoing caller name and caller ID based on outgoing caller ID number
In the case below, another connected PBX that is routing calls out through Asterisk can set the outgoing caller ID number but unfortunately does
not set the outgoing caller ID name.

As a workaround, custom logic below looks for specific outgoing caller ID number strings and also then sets the desired outgoing caller ID name.

Prerequisites
If FreePBX is configured to set a trunk-level caller ID override, the foreign PBX caller ID number will be overwritten before the code
below runs, so for the code below to work as expected, the FreePBX trunk setting needs to be "Allow any CID", not "Force Trunk CID"

Implementation
FreePBX provides a place to modify outgoing call logic through use of a pre-existing code hook called "macro-dialout-trunk-predial-hook". This
macro code will be called by Asterisk during each outgoing call. The code is placed into a file FreePBX reserves for user-added custom code.

vi /etc/asterisk/extensions_custom.conf
; 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)}" = "+15191234567"]?NoOp(CUSTOM:
Setting Caller ID override for source ${CALLERID(number)}))
exten => s,n,ExecIf($["${CALLERID(number)}" = "+15191234567"]?Set(CALLERID
(all)="Branch Office" <5191234567>))
; 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" <5192345678>))
; exit back
exten => s,n,MacroExit()

Reload the FreePBX configuration


For the changes to take effect, the FreePBX configuration needs to be reloaded by submitting any configuration page in the Web GUI and
clicking "Apply Config" or using the "amportal a r" command line command.

see amportal commands

You might also like