[Asterisk-Users] Call forwarding

William Waites asterisk at lists.styx.org
Thu Feb 17 10:53:32 MST 2005


Wow. This list is high traffic.... Just to add to the noise, here's
some of my extensions.conf that implements what you are talking about.
In particular, the macro "featureexten" takes an argument that is the
same as the context the user uses for outbound dialing. The result
being that whatever number the user puts in the CFIM database is
dialed in the same way that it would be if the user dialed it directly
from their telephone. It is used like this:

exten => 5551212,1,Macro(featureexten,usercontext,SIP/whatever,${EXTEN})

Normally [usercontext] will include => [features]

Of course beware that this is only accessible from lines that have their
callerid forced to something reasonable, else you can steal lines...

[features]
; Unconditional Call Forward
exten => _*21X.,1,Answer()
exten => _*21X.,2,DBput(CFIM/${CALLERIDNUM}=${EXTEN:3})
exten => _*21X.,3,Playback(unconditional)
exten => _*21X.,4,Playback(call-forwarding)
exten => _*21X.,5,SayDigits(${EXTEN:3})
exten => _*21X.,6,Hangup()
exten => #21,1,Answer()
exten => #21,2,DBdel(CFIM/${CALLERIDNUM})
exten => #21,3,Playback(unconditional)
exten => #21,4,Playback(call-forwarding)
exten => #21,5,Playback(disabled)
exten => #21,6,Hangup()

; Call Forward on Busy or Unavailable
exten => _*61X.,1,Answer()
exten => _*61X.,2,DBput(CFBS/${CALLERIDNUM}=${EXTEN:3})
exten => _*61X.,3,Playback(call-forwarding)
exten => _*61X.,4,Playback(on-busy)
exten => _*61X.,5,SayDigits(${EXTEN:3})
exten => _*61X.,6,Hangup
exten => #61,1,Answer()
exten => #61,2,DBdel(CFBS/${CALLERIDNUM})
exten => #61,3,Playback(call-forwarding)
exten => #61,4,Playback(on-busy)
exten => #61,5,Playback(disabled)
exten => #61,6,Hangup()

; Hide Caller-ID
exten => _*67X.,1,SetCIDNum()
exten => _*67X.,2,SetCIDName(UNKNOWN)
exten => _*67X.,3,Goto(${EXTEN:3},1)

; Last Number
exten => *69,1,Answer()
exten => *69,2,DBget(temp=LCN/${CALLERIDNUM})
exten => *69,3,Playback(last-num-to-call)
exten => *69,4,SayDigits(${temp})
exten => *69,5,Hangup
exten => *69,103,Playback(im-sorry)
exten => *69,104,Playback(num-not-in-db)
exten => *69,105,Hangup

; Call-Centre
exten => *66,1,AgentLogin(${CALLERIDNUM})

; Voicemail
exten => *98,1,VoiceMailMain(${CALLERIDNUM})

[macro-featureexten]
;
; Standard extension macro (with call forwarding):
; ${ARG1} - forwarding context/dialplan
; ${ARG2} - Device(s) to ring
; ${ARG3} - voicemailbox
;
exten => s,1,DBPut(LCN/${MACRO_EXTEN}=${CALLERIDNUM})
exten => s,2,DBget(temp=CFIM/${MACRO_EXTEN}) ; Get CFIM key, if not existing, goto 102
exten => s,3,Goto(${ARG1},${temp},1)      ; unconditional forward
exten => s,4,ChanisAvail({ARG2})
exten => s,5,Dial(${AVAILORIGCHAN},30)
exten => s,6,DBget(temp=CFBS/${MACRO_EXTEN}) ; Get CFBS key, if not existing, goto 105
exten => s,7,Goto(${ARG1},${temp},1)         ; Forward on busy or unavailable

; No CFIM key
exten => s,103,Goto(s,4)

; No available channels
exten => s,105,Goto(s,107)

; No CFBS key - voicemail ?
exten => s,107,VoiceMail(u${ARG3})


On Fri, Feb 04, 2005 at 09:22:21AM -0500, Adam Robins wrote:
> I've written a macro that allows users to dynamically change their call
> forwarding destination.  The purpose is to set up a "follow me" process
> where a user can get calls on their cell, at home, etc., based on the
> forwarding number they enter.  Using the CFIM database, I have the setup
> portion working great.  Now, I want to actually use that information to
> forward a call.  
>  
> Here is my issue:  The forwarded number saved in CFIM could be another
> extension, a local number or an LD number, each of which would be dialed
> using a different technology (internal, SIP-provider, Zap, etc.).  I
> want to avoid having to check the number and code all of the logic for
> each method - because I already have all of this set up in the dialplan
> for callers who would have dialed this forwarded number directly.
>  
> What I would like to do is take the variable containing the number
> retrieved from CFIM, place it on the stack as the called number, and
> have it reenter the dial plan, similar to the WAITEXTEN command.
>  
> Any ideas are appreciated!
>  
> For those interested, here is the "Forwarding Setup" macro:
>  
> ;
> ; 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
> 
>  
> 
> 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.
> 
> 
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
William Waites, Consulting Technologist
Consultants Ars Informatica S.A.R.F.
ww at groovy.net / +1 416 848 1527 x514
                +1 514 963 4096 (Direct)



More information about the asterisk-users mailing list