Search

Monday, December 02, 2013

Elastix : How to automatically add '9' to all incoming calls

You have setup an Elastix with T1 connectivity to PSTN.  You can also dial '9' to pickup the T1 trunk and dial out.  However, you soon find that it is inconvenient to dial a missed call on your phone simply because the caller number just does not have a '9' in front of it.

Here shows how to automatically add a '9' to all incoming calls in Elastix.

  • Edit /etc/asterisk/extensions_override_elastix.conf

  • Append below lines.  These codes add '9' in front of the caller number if it looks like a local one (8 digits in our case).

[macro-user-callerid]
include => macro-user-callerid-custom
exten => s,1,Set(AMPUSER=${IF($["foo${AMPUSER}" = "foo"]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?report)
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["x${AMPUSERCIDNAME:1:2}" = "x"]?report)
exten => s,n,Set(AMPUSERCID=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})})
exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" <${AMPUSERCID}>)
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != ""]?Set(CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)}))
exten => s,n(report),GotoIf($[ "${ARG1}" = "SKIPTTL" ]?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(2)
exten => s,n,Playback(im-sorry&an-error-has-occured&with&call-forwarding)
exten => s,n,Macro(hangupcall,)
exten => s,n,Congestion(20)
exten => s,n(continue),Noop(Original Using CallerID ${CALLERID(all)})
exten => s,n,Set(CALLERID(number)=${CALLERID(number):0:40})
exten => s,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => s,n,ExecIf($[ LEN(${CALLERID(number)}) = 8 ]?Set(CALLERID(number)=9${CALLERID(number)}))
exten => s,n,Noop(Using CallerID ${CALLERID(all)})
exten => h,1,Macro(hangupcall,)

; end of [macro-user-callerid]

  • This approach basically supercedes the original  [macro-user-callerid] of Elastix and you have control on how the caller id would be presented to your extensions.  However, if you upgrade Elastix later, you need to check if these customization align with the upgraded Elastix source code .


No comments:

Post a Comment