8 июл. 2019 г.

Set outbound CallerID Asterisk

Before Dial() command call the macro
You can use REGEX for extensions list or just compare one number.
[macro-SetOutCID]
exten => s,1,Verbose("External Caller ID setting for internal ${CALLERID(num)}...")
 same => n,ExecIf($[${REGEX("^(1011|1012|1013|1014)" ${CALLERID(num)})}]?Set(CALLERID(num)=4953229131))
 same => n,ExecIf($["${CALLERID(num)}" = "1040"]?Set(CALLERID(num)=4953229146))
 same => n,ExecIf($["${CALLERID(num)}" = "1041"]?Set(CALLERID(num)=4953229141))
 same => n,ExecIf($[${REGEX("^(1042|1043)" ${CALLERID(num)})}]?Set(CALLERID(num)=4953229156))
 same => n,ExecIf($["${CALLERID(num)}" = "1050"]?Set(CALLERID(num)=4953229151))
 same => n,ExecIf($["${CALLERID(num)}" = "2002"]?Set(CALLERID(num)=4953229120))
; and so on 
 same => n,ExecIf($["${CALLERID(num)}" = "5014"]?Set(CALLERID(num)=4953229198))
; last chance -  if no other options, set 4953229141 !!!
 same => n,ExecIf($[${LEN(${CALLERID(num)})} = 4]?Set(CALLERID(num)=4953229141))
 same => n,ExecIf($[${LEN(${CALLERID(num)})} = 0]?Set(CALLERID(num)=4953229141))
 same => n,Verbose("Outbound CallerID Set to ${CALLERID(num)}")