[Asterisk-Users] Call forwarding

Adam Robins arobins at PharmaCentra.com
Fri Feb 4 07:22:21 MST 2005


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.





More information about the asterisk-users mailing list