[Asterisk-Users] Call forwarding

Adam Robins arobins at PharmaCentra.com
Fri Feb 4 14:26:32 MST 2005


Here is the dial plan. Uses CVS-HEAD features for call screening.  This
is a pre-production system.  We will be replacing our existing Comdial
within the next few weeks.


;=====================================================================
; extensions.conf file
;=====================================================================
; Office extensions are 10-59
; Directory-by-name is *
; Parking extensions are 70-75
; Voicemail extension is 77 or #
; Music-on-hold test is 76
; MeetMe conference rooms are 81,82,83
; Polycom conference phone is 61
; Call Forward is 91
; DISA is 99
;

[general]
static=yes
writeprotect=no

[globals]
ZAPPHONE = Zap/1
ZAPLINE  = Zap/4
IAXNET = IAX2/iaxtel_out
;
; Macro for personal office extensions
;
[macro-ext]
exten => s,1,GotoIf($[${LEN(${INCOMING})} > 0]?2:211)                  ;
If call is from outside, execute screening
exten => s,2,System(test -e
/var/spool/asterisk/voicemail/default/${ARG1}/greet.gsm)   ; check if
recorded name exists
exten =>
s,3,Playback(/var/spool/asterisk/voicemail/default/${ARG1}/greet)
; play recorded name
exten => s,4,Goto(s,104)                                               ;
skip playing number if played name
exten => s,103,SayNumber(${ARG1},f)                                    ;
else play extension number
exten => s,104,Wait(1)
exten => s,105,Playback(screen-record)                                 ;
ask caller to id self
exten => s,106,SetVar(SCREEN_FILE=/tmp/${CALLERIDNUM}-${EPOCH})        ;
set file name
exten => s,107,Record(${SCREEN_FILE}.gsm|3|10)                         ;
record response to file
exten => s,108,DBget(fn=CFIM/${ARG1})                                  ;
is number forwarded?
exten =>
s,109,Dial(Local/${fn}@intl-access/n|24|gM(screen^${SCREEN_FILE})) ;
forwarded - screen to new number
exten => s,110,Goto(s,313)
exten => s,209,Dial(SIP/${ARG1}|24|tgM(screen^${SCREEN_FILE}))         ;
not forwarded - screen to extension
exten => s,210,Goto(s,313)

; call is from inside - no screening
exten => s,211,DBget(fn=CFIM/${ARG1})                                  ;
is number forwarded?
exten => s,212,Dial(Local/${fn}@intl-access/n|24)                      ;
forwarded, so send forwarding number back in
exten => s,213,Goto(s,313)
exten => s,312,Dial(SIP/${ARG1}|24|t)                                  ;
not forwarded, normal dial

exten => s,313,Voicemail(u${ARG1})                                     ;
voicemail if unavailable or busy
exten => s,314,Hangup

;
; Macro for call screening
;
[macro-screen]
exten => s,1,Wait(1)
exten => s,2,Playback(screen-from)
exten => s,3,Playback(${ARG1})
exten => s,4,Read(ACCEPT|screen-accept|1)
exten => s,5,GotoIf($[${ACCEPT} = 1 ] ?7:6)
exten => s,6,SetVar(MACRO_RESULT=CONTINUE)
exten => s,7,System(/bin/rm ${ARG1})

;
; Call forwarding Macro
;
[macro-forwarding]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,DigitTimeout(3)
exten => s,4,ResponseTimeout(10)
exten => s,5,Read(fwext,fw-extension,2)                    ; ask
extension (2 digits)
exten => s,6,Authenticate(/etc/asterisk/authFWD)           ; only
authorized individuals
exten => s,7,Playback(fw-extension)                        ; repeat back
extension
exten => s,8,SayNumber(${fwext},f)
exten => s,9,DBget(fwnum=CFIM/${fwext})                    ; check if
already forwarded

; ext is forwarded
exten => s,10,Playback(fw-is-forwarded-to)                 ; play
forwarded number from database
exten => s,11,SayDigits(${fwnum})
exten => s,12,Read(resp,fw-cancel-1-change-2,1)            ; 1 to cancel
fwd, 2 to change #
exten => s,13,GotoIf($[${resp} = 1]?17:14)                 ; 1 entered,
goto delete
exten => s,14,GotoIf($[${resp} = 2]?111:15)                ; 2 entered,
jump to change number
exten => s,15,Playback(fw-invalid-response)                ; invalid
response, loop back
exten => s,16,Goto(s,12)
exten => s,17,DBdel(CFIM/${fwext})                         ; delete
entry from database
exten => s,18,Playback(fw-call-fwd-canceled)               ; give status
& end call
exten => s,19,Playback(fw-goodbye)
exten => s,20,Hangup

; ext is not forwarded
exten => s,110,Playback(fw-is-not-currently-forwarded)     ; say number
is not forwarded
exten => s,111,Playback(fw-enter-new-forwarding-number)    ; ask for new
number
exten => s,112,Read(fwnum,fw-press-pound-when-finished)    ; accept new
number, since variable length, ask for #
exten => s,113,GotoIf($[${LEN(${fwnum})} < 2]?114:116)     ; if len < 2
then bad number
exten => s,114,Playback(fw-invalid-response)
exten => s,115,Goto(s,111)
exten => s,116,Playback(fw-you-entered)                    ; repeat back
number
exten => s,117,SayDigits(${fwnum})
exten => s,118,Read(resp,fw-if-corr-press-1-otherwise-2,1) ; confirm 1
if correct, 2 if not
exten => s,119,GotoIf($[${resp} = 1]?120:111)              ; if 1,
proceed and update db, else loop back
exten => s,120,DBdel(CFIM/${fwext})                        ; delete db
exten => s,121,DBput(CFIM/${fwext}=${fwnum})               ; add new db
entry
exten => s,122,Playback(fw-ext-is-forwarded)               ; give status
& end call
exten => s,123,Playback(fw-goodbye)
exten => s,124,Hangup




[extensions]

include => parkedcalls               ; allow call parking per
features.conf
;
; Operator - goto main menu
;
exten => 0,1,Goto(incoming,s,1)
;
; Access Voicemail - Ext 77 or #
;
exten => 77,1,Answer
exten => 77,2,Wait(1)
exten => 77,3,VoicemailMain(${CALLERIDNUM})
exten => 77,4,Hangup

exten => #,1,Answer
exten => #,2,Wait(1)
exten => #,3,VoicemailMain(${CALLERIDNUM})
exten => #,4,Hangup
;
; DISA
;
exten => 99,1,DISA(/etc/asterisk/authDISA|intl-access)
;
; Music-on-hold
;
exten => 76,1,Answer
exten => 76,2,Wait,1
exten => 76,3,MusicOnHold,default
;
; MeetMe conference rooms - defined in meetme.conf.  Require pin codes &
play MOH to first caller
;
exten => _8[1-3],1,MeetMe(${EXTEN}|Mp)
;
; Call Forwarding Setup extension
;
exten => 91,1,Macro(forwarding)
;
; Directory
;
exten => _*,1,Answer
exten => _*,2,Wait(1)
exten => _*,3,Directory(default|extensions)
exten => _*,4,Goto(incoming,s,1)
;
; Conf Room - Analog Zap Phone
;
exten => 61,1,Dial(${ZAPPHONE},24)      ; Ring for 24 seconds
exten => 61,2,Hangup                    ; Hang up if extension doesn't
answer
exten => 61,102,Busy                    ; Busy if extension is busy

;
; SIP Office Extensions - use macro-ext macro defined above
; Be sure to create corresponding entry in sip.conf and voicemail.conf
;
exten => 14,1,Macro(ext,14)
exten => 34,1,Macro(ext,34)
;
;
; play invalid msg and send back to main greeting if invalid ext entered
;
exten => i,1,Playback,invalid
exten => i,2,Goto(incoming,s,1)


[incoming]
;
; Incoming calls with no destination land here (usually from the PSTN)
;
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,DigitTimeout(3)            ; Set Digit Timeout to 3 seconds
exten => s,4,ResponseTimeout(7)        ; Set Response Timeout to 7
seconds
exten => s,5,SetVar(INCOMING=1)         ; Set variable to indicate call
from outside
exten => s,6,Background(vm-mainext)     ; Play main greeting
exten => s,7,WaitExten(5)               ; Wait for extension

;
; Hang up the line if the caller doesn't do anything
;
exten => t,1,Hangup
;
; Allow incoming calls from the outside to dial our internal extensions
;
include => extensions
;

[emergency]
;
; 911 and 411 Assistance over ZAP analog line
;
exten => _9[49]11,1,Dial(${ZAPLINE}/${EXTEN:1}) ; strip off leading '9'
exten => _9[49]11,2,Congestion
exten => _9[49]11,102,Busy
exten => _[49]11,1,Dial(${ZAPLINE}/${EXTEN:0}) ; no leading '9'
exten => _[49]11,2,Congestion
exten => _[49]11,102,Busy

[intl-trunks]
;
; International using 011 country code
;
exten => _9011.,1,Dial(SIP/${EXTEN:1}@broadvoice)
exten => _9011.,2,Congestion

[toll-trunks]
;
; Outbound to 1-nxx-nxx-xxxx are LD and go via Broadvoice
;
exten => _91NXXNXXXXXX,1,Dial(SIP/${EXTEN:2}@broadvoice)
exten => _91NXXNXXXXXX,2,Congestion

[local-trunks]
;
exten => _9NXXNXXXXXX,1,Dial(SIP/${EXTEN:1}@broadvoice)
exten => _9NXXNXXXXXX,2,Congestion

[iaxtel]
;
; 700 numbers go thru iaxtel server at Digium
;
exten => _91700NXXXXXX,1,Dial(${IAXNET}/${EXTEN:1})

[local-access]
;
; Extensions that are this context are allowed to only call local
numbers and other extensions
;
ignorepat => 9                  ; Continue dialtone after  "9" only
works on ZAP
include => extensions
include => emergency
include => iaxtel
include => local-trunks         ; Access to Local numbers

[toll-access]
;
; Extensions that are this context are allowed to call local, long
distance and other extensions
;
ignorepat => 9                  ; Continue dialtone after "9" only works
on ZAP
include => local-access         ; Everything local-access has
include => toll-trunks          ; Access to toll numbers

[intl-access]
;
; Extensions in this context can call international, ld, local and other
extensions
;
ignorepat => 9
include => intl-trunks
include => toll-access                          

The contents of this email message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply email and delete this message and its attachments, if any.





More information about the asterisk-users mailing list